[Pm-utils] POSIXification of pm-utils

Dan Nicholson dbn.lists at gmail.com
Sun Jan 13 08:53:29 PST 2008


On Jan 13, 2008 12:58 AM, Till Maas <opensource at till.name> wrote:
> On Sun January 13 2008, Till Maas wrote:
> > On Sun January 13 2008, Victor Lowther wrote:
> > > Major changes:
> > > * Renamed the hooks directory to sleep.d
> >
> > I like this
>
> I just noticed this: Here a big change in beheaviour is, that now pm-powersave
> also evaluates /etc/pm/config.d.
>
> > http://hg.fnordovax.org/pm-utils/file/4ec061123d4f/src/pm/functions
> >        58     local bases=$(for f in $syshooks/*[!~] $phooks/*[!~];
> >        59             do echo ${f##*/} ; done |
> >        60             sed 's/\*\[\!\^\]//g' |sort -n | uniq)
> >
> > I guess the "^" should be a "~" in the sed regular expression. I do not
> > know, but is there no nicer solution to implement the bash "nullglob"
> > feature? Repeating the pathname-expansion pattern with a lot of backslashes
> > for sed.
>
> The only other solution I know would be something like
> for file in $(ls $syshooks/*[!~] $phooks/*[!~])
> do
>  echo ${f##*/}
> done | sort -n | uniq

I'm not sure if I'm following the whole discussion, but why not just
do a file test like you did in the other part?

local bases=$(for f in $syshooks/*[!~] $phooks/*[!~]; do
                             [ -f "$f" ] || continue; echo ${f##*/}; done |
                             sort -n | uniq)

Another possibility is a case statement since you can use globbing easier.
case "$f" in
*'*'*) echo "this filename has a wildcard in it; skipping" ;;
*) ..whatever you normally do... ;;
esac

--
Dan


More information about the Pm-utils mailing list