bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: docs incorrectly mention pattern matching works like pathname expans


From: Stormy
Subject: Re: docs incorrectly mention pattern matching works like pathname expansion
Date: Fri, 16 Mar 2018 11:34:28 +0000 (UTC)

thanks for the help, yeah, i see, bash 4.2.26 is "old" :) :) found the 4.4:
https://tiswww.case.edu/php/chet/bash/NEWS
s.  The `local' builtin takes a new argument: `-', which will cause it to save
    and the single-letter shell options and restore their previous values at
    function return.
ok, thanks for the help all.
 

    On Friday, March 16, 2018, 12:48:04 PM GMT+2, Robert Elz 
<kre@munnari.OZ.AU> wrote:  
 
     Date:        Fri, 16 Mar 2018 10:04:07 +0000 (UTC)
    From:        Stormy <stormy1777@yahoo.com>
    Message-ID:  <1098519022.1750755.1521194647970@mail.yahoo.com>

  | however, both paths need to be normalized fully before

Yes, you're right, I did not consider that, but skipping empty
pathname components should be easy enough to add
(and pattern components if you need to)

I also did not include code to make sure /fff only matches /???
and that fff only matches ??? (etc) - ie: to check that both
refer to the root, or neither does.

  | also I'm completely unaware of the "-" in local, it gave me:
  | ./fnmatch.sh: line 3: local: `-': not a valid identifier

If you're using bash that means you're using an older version.
If you're not using bash, that is to be expected (the chances that
you're using the NetBSD or FreeBSD shell is small, I am not sure
if dash includes "local -" or whether it split from the other ash
derived shells before that was added.)

  | took it out, and script seems to work,

Without "local -" you would need to restore the setting of
the 'f' option before the function returns.  Something like

    OPTS="$(set +o)"
in the init code (where OPTS is yet another local var...)
and then
    eval "$OPTS"
just before each "return" (which will mean adding { } in
one case) and before the final [ ] command that sets
the exit code for when the function falls off the bottom.

This is kind of overkill for just -f and there are other ways
to save and restore just that option, but this is the easiest.

kre

  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]