Bash command separator/arguments separator
Is there a simple way to force BASH *not* to use the ";" character as shown below:
Code:
$ command_1 ; command_2 ; ... ; command_n Code:
$ command_1 ! command_2 ! ... ! command_n Alas, should you want to pass a space-infested string as the first argument to a program, a construction of the following sort has to be used: Code:
$ program "this is argv1" Code:
$ program !this is argv1! |
No, you can't replace double quote with anything else.
|
You can't easily replace the quotes, but the separator character can be chaged with the 'IFS' variable (Internal File Separator). The standard setting for this is equivalent to 'space,tab,end-of-line'. Usually, if you are going to change it in a script you save the original value so it can be restored for normal use in other loops, so you atrt by putting:
OLDIFS=$IFS IFS='whatever separator' code.... IFS=$OLDIFS |
I don't think you can replace ';', that's not part of IFS, it's a cmd separator, different concept.
IFS: http://dict.die.net/ifs/ |
Hello. Sorry, I was *actually* looking for the variable that contains the character(s) that separates arguments passed to a program. I understand this is IFS, however, I do not understand why this does not work:
Code:
$ IFS=: Code:
$ IFS=: |
Try following:
Code:
$bash -c 'IFS=":"; files="a.txt:b.txt"; ls -l $files' |
Hi.
From the O'Reilly book: Quote:
|
Maybe you can somehow wrap the command lines with sed? I'm not sure how you'd do that, but it sounds entirely plausible. I don't know if it could be done transparently unless you created a wrapper program which created a vterm and passed everything along to the "real" term while filtering typed input.
ta0kira |
Hi.
Quote:
To parse a string, assign it to a variable, set IFS, and use the results. Reset IFS afterwards as necessary. The example from rsashok illustrates this. Or am I missing something? ... cheers, makyo |
You prob need to use single quotes around it, to avoid it being used as the bash built-in do-nothing/null cmd:
Code:
: [builtin] - do nothing; this builtin has no effect eg Code:
if [[ complextest ]] |
Hello. Perhaps some (most/all?) of the people who read the thread are wondering about why I care about IFS. I /care/ about it because I am trying to understand why the system() function is considered insecure (according to its manual page). See this thread for a few details: http://www.linuxquestions.org/questi...secure-603187/
|
See my answer there....
|
All times are GMT -5. The time now is 08:30 AM. |