On Oct 10, 2010, at 4:51 PM, Garance A Drosihn wrote: > On 10/10/10 7:09 PM, Devin Teske wrote: >> However, enclosing the argument (as the 'x$foo' portion is really just the >> first argument to the '[' built-in) in quotes: >> >> [ "$foo" = x ] >> >> makes it so that the expansion is taken as: >> >> [ "-n" = x ] >> >> rather than: >> >> [ -n = x ] >> >> The former not causing an error, while the latter does. >> > The latter does not cause an error. Try it: > > # [ "-n" = x ] ; echo $? > 1 > > # [ -e = "no" ] ; echo $? > 1 > > # [ -e = -n ] ; echo $? > 1
Logical error, not functional error. >> Quite functionally, at a C-level, if you have your array, ... >> >> argv[0] = "[\0"; >> argv[1] = "\"-n\"\0"; /* quoted syntax */ >> argv[2] = "=\0"; >> argv[3] = "x\0"; >> >> and >> >> argv[0] = "[\0"; >> argv[1] = "-n\0"; /* non-quoted syntax */ >> argv[2] = "=\0"; >> argv[3] = "x\0"; >> >> > You won't see the double-quotes in the C program. Correct, an external C programming will get the arguments just like a shell script. > The shell processes single and double quotes, and passes the result to the > C program which is running. It might be different for built-in functions, Indeed it is. > but /bin/test would never see the double-quotes if they were used. And since > the built-in function has to work the same as standalone function There is no distinction between "built-in function" and "standalone function". I think you mean "built-in" versus "external binary". The way that parameters are passed off to the internal parser is different than the way arguments are passed to external executables. > , I doubt the built-in would be any different. > > # list_args "-n" > > list_args at 19:36:15 Oct 10: $# = 1 > ARG[000] l=002: '-n' > # list_args -n > > list_args at 19:36:22 Oct 10: $# = 1 > ARG[000] l=002: '-n' > > (note that the single-quotes you see there are printed by the list_args > script itself for display purposes). > > disclaimer: I think this is the first post that I've made with the new > "open-source edition" of Eudora, and I have no idea if this will be formatted > the way I'm expecting it be! > > -- > Garance Alistair Drosehn = dro...@rpi.edu > Senior Systems Programmer or g...@freebsd.org > Rensselaer Polytechnic Institute; Troy, NY; USA > -- Cheers, Devin Teske -> CONTACT INFORMATION <- Business Solutions Consultant II FIS - fisglobal.com 510-735-5650 Mobile 510-621-2038 Office 510-621-2020 Office Fax 909-477-4578 Home/Fax devin.te...@fisglobal.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.1 GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h r>++ y+ ------END GEEK CODE BLOCK------ http://www.geekcode.com/ -> END TRANSMISSION <- _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"