LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2013, 03:45 AM   #1
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Modifying zsh glob expansion in variables.


Hi all,

does anyone know of a zsh option that will make shell globs in variables expand? Here I try to illustrate the situation. The following would happen in zsh:
Code:
% touch a b c
% fs="*"
% echo $fs
*
The same thing in bash, dash or ksh will output "a b c".

Does anyone know of a option in zsh that would get it to behave like these other shells? I did check the zshoptions man page but have not found anything that does what I'd like. I'd really like to find a simple workaround here, I don't want to have to switch to bash, or have to patch a bunch of scripts. Any ideas?

The above example is the simplest that illustrates the problem, the bigger problem is that in the environment I work in, there are large number of scripts that must be sourced to use some in house software. There are scripts to source for bourne shell users (in practice a hundred or so bash users), and an alternative set of scripts exist for csh users (in practice a few dozen tcsh users). AFAIK, I'm the only zsh user.

TIA,

Evo2.

Last edited by evo2; 05-01-2013 at 03:52 AM.
 
Old 05-01-2013, 04:55 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Hi,
What exactly are you trying to do?
I've never used zsh, but after a quick glance at the manual:

man zshoptions:
Code:
       GLOB_SUBST <C> <K> <S>
              Treat any characters resulting from parameter expansion as being eligible for  file
              expansion  and  filename generation, and any characters resulting from command sub‐
              stitution as being  eligible  for  filename  generation.   Braces  (and  commas  in
              between) do not become eligible for expansion.
Code:
% setopt GLOB_SUBST
% touch a b c
% fs="*"
% echo $fs
a b c
Also, please note that, like in bash, the glob expansion happens after parameter substitution, not during assignment.

Last edited by millgates; 05-01-2013 at 05:05 AM.
 
1 members found this post helpful.
Old 05-01-2013, 07:09 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Original Poster
Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by millgates View Post
I've never used zsh, but after a quick glance at the manual:
<snip>

Opps, seems I should have spent more time in that man page...

Thanks, GLOB_SUBST seems to be exactly what I was looking for.

Cheers,

Evo2.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Zsh, glob with style LXer Syndicated Linux News 0 10-23-2010 07:41 PM
SED: wildcard expansion in variables Gracie Belle Linux - Newbie 3 02-20-2008 07:43 AM
Bash variables expansion olaola Linux - Newbie 4 10-16-2006 11:45 AM
ssh : remote command execution doesn't work for modifying env variables pypieuvre Programming 10 02-24-2006 09:50 AM
modifying environment variables zulu1_hl Linux - Newbie 5 02-26-2003 10:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration