[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: allow shif [n] with n > $#
From: |
Greg Wooledge |
Subject: |
Re: feature request: allow shif [n] with n > $# |
Date: |
Mon, 15 Apr 2019 09:19:19 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Mon, Apr 15, 2019 at 08:42:53AM -0400, Greg Wooledge wrote:
> On Sat, Apr 13, 2019 at 09:43:47AM +0200, Toralf Förster wrote:
> > Except, that I used the opposite:
> >
> > min_days=${1:-5}
> > min_hours=${2:-12}
> > min_compl=${3:-3500}
> > shift "$(( $# < 3 ? $# : 3 ))"
> > setupargs="$@"
>
> So... this user interface of yours. It looks something like
>
> myprog [days] [hours] [compl] [file ...]
>
> So if the user passes two numeric arguments and then a filename, the
> third filename becomes "compl" (whatever that is, but it seems to be
> numeric)?
>
> If the user passes two numeric arguments and then 17 filenames, the
> first filename becomes "compl" and gets shifted away, and then only
> the last 16 filenames are processed?
>
> I'm seeing a whole lot of pitfall here and not much safety net.
Also, you are squashing all of your filename arguments down into a
single string variable, presumably to be word-split later. Which
will blow up when one of those arguments contains whitespace or glob
characters.
If you want to store a list of arguments, use an array variable instead
of a string variable.