Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: [PATCH] Make incorrect ftp(1) usage more obvious
Cc:
"H. Hartzer" <h@hartzer.sh>, tech@openbsd.org
Date:
Fri, 02 May 2025 09:48:48 -0600

Download raw body.

Thread
Theo de Raadt <deraadt@openbsd.org> wrote:

> H. Hartzer <h@hartzer.sh> wrote:
> 
> > Hi tech@,
> > 
> > I'm coming from a background of curl, wget, and fetch where I
> > frequently run my commands with the options after, like:
> > curl https://openbsd.org -o index.html
> > Unfortunately, this makes ftp(1)'s behavior a bit confusing.
> > 
> > For example:
> > 
> > ftp https://openbsd.org/index.html -o dir/openbsd-index.html
> > will silently put index.html into the current directory and exit 0.
> > 
> > ftp(1) only accepts arguments at the start of the command. None after
> > the URL(s).
> > 
> > This patch informs the user if they are making such a mistake. It also
> > adjusts the exit code for usage errors to 2, which makes testing a
> > little bit easier. It includes some basic regression testing.
> > 
> > Let me know if you have any questions or if this needs any adjustments.
> 
> 
> I disagree strongly.
> 
> We follow original POSIX getopt(3) rules in every program, using libc code.
> 
> This applies to ALL commands.  No commands are different.
> 
> It means all options must be before non-option arguments.
> 
> Placing options after non-options is going to break on any non-GLIBC/MUSL
> system, and you are going to need to get used to that being the wrong
> thing to do and put your arguments in the standards-mandated order.

Let me put it this way.

% ls /bin -FC
ls: -FC: No such file or directory
/bin:
[*           cp*          domainname*  kill*        mt*          rm*          sleep*
cat*         cpio*        echo*        ksh*         mv*          rmdir*       stty*
chgrp*       csh*         ed*          ln*          pax*         sh*          sync*
chio*        date*        eject*       ls*          ps*          sha1*        tar*
chmod*       dd*          expr*        md5*         pwd*         sha256*      test*
cksum*       df*          hostname*    mkdir*       rksh*        sha512*


You want to add such a change to every command?  Adding it just one, for your
finger memory convience, is not reasonable.