From: janis_papanagnou+ng@hotmail.com   
      
   On 08.11.2025 04:00, Keith Thompson wrote:   
   > Janis Papanagnou writes:   
   > [...]   
   >> The problem with a choice of -h for that is that this letter h might   
   >> be a good choice for an existing functional option and would then not   
   >> be available any more for that. (I thus consider this "convention" a   
   >> badly decided thing as far as -h is concerned, while --help is okay.)   
   >>   
   >> We've thus used -? for that usage purpose, a _non-letter_ character;   
   >> it was standard in all our tools and I'm still using that convention   
   >> in my private context.   
   > [...]   
   >   
   > '?' is a shell wildcard, matching a single character in a file name.   
      
   Yes, any files named like will get then expanded   
   in standard Unix shell (with standard settings), and one should   
   be aware of that. It's good to mention that (since I forgot to   
   do so)!   
      
   In decades of practice I've not met such filenames in practice,   
   though; and that's explainable, because it's semantically an   
   arguably sensible name, and if you have files with such names   
   you usually cannot use most of the Unix tools anyway (without   
   precautions) since such filenames would be interpreted in tools   
   as option so that most tools won't work with them; then you'd   
   have to also indicate end-of-options with the tool (like '--')   
   or use tool-specific "escape-options" (like in grep with '-e').   
      
   But there sometimes also erroneously created files with such   
   names in the file system, and (as you subsequently demonstrate   
   it) such an inadvertently created file may make troubles then.   
      
   >   
   > "foo -?" will expand to "foo -x" if you happen to have a file in   
   > the current directory named "-x" (and foo's "-x" option obviously   
   > tells it to delete your home directory). If you have no such file,   
   > the behavior of "foo -?" depends on your shell and its settings,   
   > but typically no substitution takes place.   
      
   (Or in shell context, where appropriate, you can also just   
   disable the filename globbing so that it doesn't expand.)   
      
   >   
   > This is specific to the behavior of shells on Unix-like systems,   
   > but if you're writing a C program intended to work on such systems   
   > (and possibly others), it's good to be aware of the issue.   
   >   
   > Few Unix commands use "-?" to mean "print a usage message".   
   > For those that do, I would escape the question mark.   
      
   In practice it doesn't seem to be necessary (mileages may   
   vary), but quoting "locally" disables expansions and makes   
   it safer for contexts where such filenames are used, indeed.   
      
   Though, the additional characters (-\? or "-?" or '-?') may   
   be considered an annoyance and a suboptimal choice of -? in   
   the first place for contexts with dash-char named files.   
      
   Janis   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|