passing argument with brace expansion to script
Hi! I have a script to which I would like to pass an argument that contains brace expansion, but I want the expansion to be evaluated in the script, not before it gets passed along. Does annyone know how to do that? TIA Andreas -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: passing argument with brace expansion to script
On Sun, Jan 13, 2008 at 07:59:52PM +0100, Andreas Berglund wrote: > Hi! > I have a script to which I would like to pass an argument that contains > brace expansion, but I want the expansion to be evaluated in the script, > not before it gets passed along. Does annyone know how to do that? Generally single or double quotes will "protect" arguments against expansion in a shell command. The quotes are removed in the process, so the arguments should be available separately inside the script. Bash brace expansion is kind of a special case, though, and I'm not sure it'll work this way... Some simple tests would answer the question. Ken -- Ken Irving, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: passing argument with brace expansion to script
Ken Irving wrote: On Sun, Jan 13, 2008 at 07:59:52PM +0100, Andreas Berglund wrote: Hi! I have a script to which I would like to pass an argument that contains brace expansion, but I want the expansion to be evaluated in the script, not before it gets passed along. Does annyone know how to do that? Generally single or double quotes will "protect" arguments against expansion in a shell command. The quotes are removed in the process, so the arguments should be available separately inside the script. Bash brace expansion is kind of a special case, though, and I'm not sure it'll work this way... Some simple tests would answer the question. Ken I have tried the traditional techniques with quotes, single and double, and backslashes and it does get the argument to the script unchanged, but then it won't get evaluated in the script for some reason, perhaps it's not possible? -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: passing argument with brace expansion to script
On Sun, Jan 13, 2008 at 11:36:09PM +0100, Andreas Berglund wrote: > Ken Irving wrote: >> On Sun, Jan 13, 2008 at 07:59:52PM +0100, Andreas Berglund wrote: >>> Hi! >>> I have a script to which I would like to pass an argument that contains >>> brace expansion, but I want the expansion to be evaluated in the script, >>> not before it gets passed along. Does annyone know how to do that? >> >> Generally single or double quotes will "protect" arguments against >> expansion in a shell command. The quotes are removed in the process, >> so the arguments should be available separately inside the script. Bash >> brace expansion is kind of a special case, though, and I'm not >> sure it'll work this way... Some simple tests would answer the question. >> >> Ken >> > > I have tried the traditional techniques with quotes, single and double, and > backslashes and it does get the argument to the script unchanged, but then > it won't get evaluated in the script for some reason, perhaps it's not > possible? how are you using the string , with eval ? > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a > subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] > > -- "Laura and I really don't realize how bright our children is sometimes until we get an objective analysis." - George W. Bush 04/15/2000 CNBC signature.asc Description: Digital signature
Re: passing argument with brace expansion to script
On Sun, Jan 13, 2008 at 11:36:09PM +0100, Andreas Berglund wrote: > Ken Irving wrote: >> On Sun, Jan 13, 2008 at 07:59:52PM +0100, Andreas Berglund wrote: >>> Hi! >>> I have a script to which I would like to pass an argument that >>> contains brace expansion, but I want the expansion to be evaluated >>> in the script, not before it gets passed along. Does annyone know >>> how to do that? >> >> Generally single or double quotes will "protect" arguments against >> expansion in a shell command. The quotes are removed in the process, >> so the arguments should be available separately inside the script. >> Bash brace expansion is kind of a special case, though, and I'm not >> sure it'll work this way... Some simple tests would answer the question. > > I have tried the traditional techniques with quotes, single and double, > and backslashes and it does get the argument to the script unchanged, > but then it won't get evaluated in the script for some reason, perhaps > it's not possible? I think that's the case, but can't find it clearly expressed in the bash manpage. Some time ago I recall looking into brace expansion, maybe even looked at the bash source code, and I'm pretty sure it's a special feature that works well off the command line, but for some reason not after that. I'm curious about it... -- Ken Irving, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: passing argument with brace expansion to script
On Sun, Jan 13, 2008 at 02:04:59PM -0900, Ken Irving wrote: > On Sun, Jan 13, 2008 at 11:36:09PM +0100, Andreas Berglund wrote: > > Ken Irving wrote: > >> On Sun, Jan 13, 2008 at 07:59:52PM +0100, Andreas Berglund wrote: > >>> Hi! > >>> I have a script to which I would like to pass an argument that > >>> contains brace expansion, but I want the expansion to be evaluated > >>> in the script, not before it gets passed along. Does annyone know > >>> how to do that? > >> > >> Generally single or double quotes will "protect" arguments against > >> expansion in a shell command. The quotes are removed in the process, > >> so the arguments should be available separately inside the script. > >> Bash brace expansion is kind of a special case, though, and I'm not > >> sure it'll work this way... Some simple tests would answer the question. > > > > I have tried the traditional techniques with quotes, single and double, > > and backslashes and it does get the argument to the script unchanged, > > but then it won't get evaluated in the script for some reason, perhaps > > it's not possible? > > I think that's the case, but can't find it clearly expressed in the bash > manpage. Some time ago I recall looking into brace expansion, maybe even > looked at the bash source code, and I'm pretty sure it's a special feature > that works well off the command line, but for some reason not after that. > I'm curious about it... Maybe it's this bit, from bash(1), 3.1dfsg-8: Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved in the result. It is strictly textual. Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces. If the braces are in a variable then it's already too late, since bash won't see them until it expands the variable, and per the above won't do the expansion. Or something... -- Ken Irving, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: passing argument with brace expansion to script
On Sun January 13 2008 10:59:52 Andreas Berglund wrote: > I have a script to which I would like to pass an argument that contains > brace expansion, but I want the expansion to be evaluated in the script, > not before it gets passed along. Does annyone know how to do that? Have you tried eval? $ echo '$SHELL' $SHELL $ eval echo '$SHELL' /bin/bash --Mike Bird -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]