News for hackers. Stuff that matters.
Re:Unix Wildcards Gone Wild by AceJohnny2 on Sunday August 17, 2014 @03:37PM (#8190208)
David A. Wheeler, FOSS (and occasionally security) luminary, who also happens to be creator of the popular sloccount tool, has an excellent page that covers this topic and how to use paths safely and portably in shell scripts (spoiler: it's hard) :

http://www.dwheeler.com/essays/filenames-in-shell.html

I strongly recommend his many other essays to HN readers: http://www.dwheeler.com/

Edit: a simple way to avoid these problems is to prepend the wildcard with ./ (so globbed files won't start with - or -- but with the path ./) and on GNU systems put -- before the wildcard, telling the tool that following arguments are not options.

Re:Unix Wildcards Gone Wild by teddyh on Sunday August 17, 2014 @05:35PM (#8190541)
The double dash -- to stop option parsing is not a GNU thing – it comes from the POSIX standard.
Re:Unix Wildcards Gone Wild by AceJohnny2 on Sunday August 17, 2014 @05:43PM (#8190569)
Thanks! I had always figured that, along with long options, they were a GNU thing.
Re:Unix Wildcards Gone Wild by _delirium on Sunday August 17, 2014 @07:11PM (#8190798)
There's some digging here: http://unix.stackexchange.com/questions/147143/when-and-how-...

Looks like the convention was introduced as part of getopt in AT&T Unix System III (1980), though initially only in a handful of places. Then POSIX adopted it as standard for all utilities sometime later.

Re:Unix Wildcards Gone Wild by emmelaich on Sunday August 17, 2014 @07:50PM (#8190886)
They were quite distinct.

When --longopt was starting to get popular (in an ad-hoc way) for gnu and other utilities there was a poll (gnu.misc? late 90s?) whether to make it a gnu standard. The other choices were a +, or have commands not accept both bundled single letter options and longopts. There may have been other choices I've forgotten about.

The double-dash won. There were some people who were concerned that it might be confused with the end-of-args double dash.

Maybe that is true but they are certainly unambiguously parsed.

Re:Unix Wildcards Gone Wild by pmahoney on Sunday August 17, 2014 @10:31PM (#8191223)
> portably in shell scripts (spoiler: it's hard)

At what point do you give up and, if you must have portability, bootstrap a saner environment?

Are there many options in this area? Assume perl is available? Use autoconf-like shell script compiler? Starting with Lua (which I hope/assume can build anywhere, though I know it's missing lots of functionality out of the box)?

Re:Unix Wildcards Gone Wild by AceJohnny2 on Monday August 18, 2014 @03:37PM (#8194186)
I'm lucky not to have to worry about this, but I figured that having Perl is a safe assumption for desktop and server Unix systems.

Not embedded devices, but I guess those are different enough that you're probably not targetting them for portable scripts. Oh no, have I contradicted myself? :)