-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to [EMAIL PROTECTED] on 10/29/2006 5:29 PM: > But dont variables set on command line apply to everything on > that line?
Nope. According to 2.9.1 Simple Commands, variable assignments are deferred until after expansions, which include command substitution. In order to have IFS affect a command substitution, it must occur in an earlier simple command. For a one-liner, try: IFS=$'\n'; vi $(grep -l PATTERN *) The semicolon separates the variable assignment from the command. And if you don't want IFS to remain changed after the vi invocation, either use a subshell, or save and restore IFS after you are done modifying it. For example: (IFS=$'\n'; vi $(grep -l PATTERN *)) And note that you had a typo - it should be IFS=$'\n' if you want a newline, because IFS='\n' sets IFS to the two characters backslash and n rather than the one character newline. > Or is IFS not really an IFS? IFS affects ONLY the results of variable and command substitution. If it were to affect the grammar, it would be MUCH harder to write a shell. Reread POSIX 2.5.3 Shell Variables: "IFS (Input Field Separators.) A string treated as a list of characters that is used for field splitting and to split lines into fields with the read command. If IFS is not set, the shell shall behave as if the value of IFS is <space>, <tab>, and <newline>; see Field Splitting. Implementations may ignore the value of IFS in the environment at the time the shell is invoked, treating IFS as if it were not set." and 2.6.5 Field Splitting "After parameter expansion ( Parameter Expansion), command substitution ( Command Substitution), and arithmetic expansion ( Arithmetic Expansion), the shell shall scan the results of expansions and substitutions that did not occur in double-quotes for field splitting and multiple fields can result." In other words, IFS only affects the results of expansions, not literal text; words, in the sense of the shell grammar, are always delineated by unquoted space, tab, and newline, regardless of the IFS setting. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFRU2N84KuGfSFAYARAu/oAJsH/gsVVMTZm1EPkztXG8aqTUdF5gCgwRT/ 77cHdE18s8Qcuglfybexroc= =hotu -----END PGP SIGNATURE----- _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash