zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: ls *.mp4 → ls : invalid option -- 'M'
Date: Mon, 16 Oct 2023 06:35:08 -0700	[thread overview]
Message-ID: <179314f9-333c-4baa-9dab-6fa397ab2f64@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7Zwumbx0PvO-XgFoWrLuW=sTZB4tSvS4AV46Fsq0vsbfA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]


On 2023-10-15 21:25, Bart Schaefer wrote:
> Oops, that should be
>    for f in argv\[{1..$#}\]
>
>>    do
>>      [[ $f = -* && -f $f ]] && f=./$f
>>    done
>>    command ls $*
>> }
> Forgot about the special case for $1 et al. that makes them not
> directly referenceable.
>
Question:  is this not the sort of issue that in principle cannot be 
solved in an air-tight way?  If shells always expand arguments 
zealously, with the presumption that they are filenames, yet knowing 
full well that some might be switches ... sorry 'options' ... and 
whereas the standard answer is that the double dash ends options -- if 
someone has filenames that mimic de facto options when globbing is done, 
are they not a victim of their own liberty?

IOW, if Linux permits almost anything as a filename, and if some of 
those filenames look like options, and if shells diligently expand 
everything, and if various commands are free to make up their own 
syntax.  [Sorry, this is a really badly framed question. ] ... can even 
the idea of a generic zsh fix be contemplated?

I sorta see that Bart's code would sorta work, but given the inherent 
brokenness of Linux in this regard, might it be better understood that 
the solution is for people to not give weird names to files?  Or to code 
something ad hoc if they crash into this kind of thing?  I understand 
that the Linux philosophy is that you are free to do dumb things -- Unix 
was invented by hippies -- but I'm questioning whether zsh should 'get 
involved' in even a peripheral way.  If I have files named '--' and '-M' 
it might be legal but if 'ls' has trouble with it I don't think I'd 
expect zsh to try to fix that for me 'officially' that would just be 
condoning bad behavior.  Or should she? Not sure.  Philosophical issue.



[-- Attachment #2: Type: text/html, Size: 2571 bytes --]

  reply	other threads:[~2023-10-16 13:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  7:59 Denis Bitouzé
2023-10-13  8:15 ` sergio
2023-10-13  8:15 ` Mikael Magnusson
2023-10-13 11:38   ` Denis Bitouzé
2023-10-13 14:46   ` Ray Andrews
2023-10-13 15:13     ` Peter Stephenson
2023-10-13 15:58       ` Ray Andrews
2023-10-16  0:46       ` Bart Schaefer
2023-10-16  4:17         ` Bart Schaefer
2023-10-16  4:25           ` Bart Schaefer
2023-10-16 13:35             ` Ray Andrews [this message]
2023-10-16 18:21               ` Bart Schaefer
2023-10-16 19:45                 ` Ray Andrews
2023-10-17  3:49                   ` Bart Schaefer
2023-10-17 14:04                     ` Ray Andrews
2023-10-17 15:55                       ` Bart Schaefer
2023-10-17 17:03                         ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179314f9-333c-4baa-9dab-6fa397ab2f64@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).