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

Re: Bash usage: was implicit linkage



On Sun, 12 Oct 2014 11:16:54 -0700
Don Armstrong <don@debian.org> wrote:

> On Sun, 12 Oct 2014, Steve Litt wrote:
> > This essay practically screams out for somebody to write a C program
> > that takes an argument of an arbitrary string, finds all files in a
> > directory, and returns a long string with those files separated by
> > the arbitrary string.
> 
> You seem to be looking for find -print0; \0 is one of the few
> characters which is not valid to have in a file name.

Let me think about that. I wasn't aware that \0 couldn't get into a
filename. I was concerned about the following
in /http://www.dwheeler.com/essays/filenames-in-shell.html :

=========================================
"Most shells cannot store byte 0 in a variable at all. You can’t even
pass such null-separated lists back to the shell via command
substitution; cat $(find . -print0) and similar “for” loops don’t work.
Even the POSIX standard’s version of “read” can’t use \0 as the
separator (POSIX’s read has the -r option, but not bash’s -d option)."
=========================================
 
> It's not like it's that hard to do this properly in a policy compliant
> POSIX shell, either. Use IFS and reset it as appropriate, or properly
> quote things. 

I'll try these things, before writing my own "return each filename"
program. Thanks.

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance


Reply to: