4 ms·
Sometimes you need to deliberately not quote, though. For example, an output of a program might be a list of files, which I then might want to operate on using
by rlpb 5y ago
Sometimes you need to deliberately not quote, though. For example, an output of a program might be a list of files, which I then might want to operate on using "for filename in $files". If I do this then I must have a guarantee that the files do not have spaces in them, but this is usually not a particularly onerous requirement for a closed system that doesn't have untrusted filename inputs. Splitting data using text separated by whitespace is part of the essence of Unix (see TAOUP). If you want to ban this kind of thing too, then you might as well not permit shell scripting at all.
- koolba 5y agoThat’s what xargs, preferable with -0, is for. The problem with “works most of the time” is that it stops working when you’re not around. So it might be fine for a one-off shell command, but you never know what the next guy will pass into it.
- IshKebab 5y ago> you might as well not permit shell scripting at all Generally a good idea if you care about bugs at all.