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: Robert Elz
Subject: Re: docs incorrectly mention pattern matching works like pathname expansion
Date: Fri, 16 Mar 2018 17:46:38 +0700

    Date:        Fri, 16 Mar 2018 10:04:07 +0000 (UTC)
    From:        Stormy <address@hidden>
    Message-ID:  <address@hidden>

  | 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]