Re: bash - safely pass untrusted strings?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Benjamin Smith wrote:
> Unless I'm terribly mistaken (again?), the only way I've been able to see "loop thru a list of files" work reliably is with "find" using the "-print0" option, in cahoots with xargs. Is there any other way?

for $file in wildcard*
  do
    ls -l "$file"
  done

But this is the point where you should be asking what to do about quotes embedded in the filenames which won't hurt here because of the order of operations but would if you tried to collect the strings and use them in some other ways.

Does anyone have a quick reference to the order of operations as the shell parses a command line (variable parsing,i/o redirection, wildcard and variable expansion, splitting on IFS, quote removal, command substitution etc.)? That's really the first thing you need to know about the shell and if there is a simple description it must be buried in the middle of some obscure manual.

--
 Les Mikesell
   lesmikesell@xxxxxxxxx



_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux