From: alexpdp7 Date: Sat, 30 Aug 2025 09:42:54 +0000 (+0200) Subject: Quote toot X-Git-Url: https://xn--ix-yja.es/gitweb/?a=commitdiff_plain;h=1a9128e4f419122a7cb5247bfe56c25e80a577b0;p=alex.git Quote toot --- diff --git a/linux/running_commands_in_linux.adoc b/linux/running_commands_in_linux.adoc index 7e5eec5..b31c39b 100644 --- a/linux/running_commands_in_linux.adoc +++ b/linux/running_commands_in_linux.adoc @@ -285,6 +285,7 @@ So the `cat a b` statement prints the contents of the `a` and `b` files, not of == Further reading * http://teaching.idallen.com/cst8177/13w/notes/000_find_and_xargs.html[Using find -exec or xargs to process pathnames with other commands] +* https://infosec.exchange/@david_chisnall/115116683569142801[Early UNIX did glob expansion in the shell not because that’s more sensible than providing a glob and option parsing API in the standard library, but because they didn’t have enough disk space or RAM to duplicate code and they didn’t have shared libraries... For example, on FreeBSD, I often do pkg info foo* to print info about packages that start with some string. If I forget to quote the last argument, this behaves differently depending on whether the current directory contains one or more files that have the prefix that I used. If they do, the shell expands them and pkg info returns nothing because I don’t have any installed packages that match those files. If they don’t, the shell passes the star to the program, which does glob expansion but against a namespace that is not the filesystem namespace. The pkg tool knows that this argument is a set of names of installed packages, not files in the current directory, but it can’t communicate that to the shell and so the shell does the wrong thing. Similarly, on DOS the rename command took a load of source files and a destination file or pattern. You could do rename *.c *.txt and it would expand the first pattern, then do the replacement based on the two patterns. UNIX’s mv can’t do that and I deleted a bunch of files by accident when I started using Linux because it’s not obvious to a user what actually happens when you write mv *.c *.txt. There is a GNU (I think?) rename command and its syntax is far more baroque than the DOS one because it is fighting against the shell doing expansion without any knowledge of the argument structure.] == TODO