4 ms·
Reordering Arguments (2016)
- lpapez 5y agoTangential to the article; can anyone here think of a use-case for providing thousands of command line arguments to a program?
- nonameiguess 5y agoFun fact: We had an issue with a testing system I worked on years back, and it turned out SoaTest logging every single xml request it sent a mock response to as a separate file in the same directory made it impossible to delete the files with rm * because '*' overflowed the shell buffer for maximum string length. I think it was something like 60 million files that had accumulated. There was actually a tangentially similar case where we had to log all of the queued tips that get sent to the Navy's maritime domain awareness system that get purged because they aren't positively adjudicated in time, and this queue could get so large in testing environments because the system kept automatically filling the queue but no one was around to adjudicate, that the log message would grow larger than the JVM's maximum string length. Yet another where our regression test suite did a pixel-by-pixel bytewise diff of before and after images and printed to an html report. Eventually, the diffs grew so big as images kept getting larger that you couldn't open the report without crashing Firefox.
- inoffensivename 5y agoborg is a commonly-run binary at google, --helpfull prints all the arguments available to it: borg --helpfull | grep -- '^ --' | wc -l 3794 Not saying that you would need to use all of those arguments, but they are there!
- user982 5y agodu -chs *
- deleted 5y ago[deleted]
- jolmg 5y agofind $file_filters -type f -exec grep $pattern {} +
- wahern 5y agofind will only pass up to ARG_MAX arguments to each invocation of grep. > If the primary expression is punctuated by a <plus-sign>, the primary shall always evaluate as true, and the pathnames for which the primary is evaluated shall be aggregated into sets. The utility utility_name shall be invoked once for each set of aggregated pathnames. [...] The size of any set of two or more pathnames shall be limited such that execution of the utility does not cause the system's {ARG_MAX} limit to be exceeded. [....] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/f...
- deleted 5y ago[deleted]
- jolmg 5y agoThat limit is not specific to `find`. It applies to the `exec` family of functions. There's no way around it, so it also applies to globbing, command substitution, etc. Also, it's not ARG_MAX arguments; it's ARG_MAX byte length for the argument list, in addition to, on Linux, the environment list. A modern Linux machine has it set over 2,000,000, so it can easily fit 1,000 arguments.
- tingletech 5y ago2016
- deleted 5y ago[deleted]