[Pm-utils] POSIXification of pm-utils

Victor Lowther victor.lowther at gmail.com
Sun Jan 13 08:36:57 PST 2008


On Jan 13, 2008 2:12 AM, Till Maas <opensource at till.name> wrote:
> On Sun January 13 2008, Victor Lowther wrote:
>
> > Major changes:
> > * Renamed the hooks directory to sleep.d
>
> I like this
>
> > * Generalized the hook-running infrastructure and modified
> > pm-powersave to use it instead of having its own copy.
>
> and this.
>
> > Comments, patches, flames, praise, etc. welcome!
> 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.

You are correct -- I went ahead and rewrote that bit of code to
actually test for the existence of the hook instead of using sed.

> http://hg.fnordovax.org/pm-utils/file/4ec061123d4f/pm/sleep.d/zzz
> echo -e "99video\n99999suspend" | sort -n
> does work here as expected in bash. But zzz is a funny name in this
> context. :-)

When I was testing it with 9999suspend did not work reliably on my
testing system, so I changed the name to zzz and got rid of the -n
argument to sort.

>
> http://hg.fnordovax.org/pm-utils/file/4ec061123d4f/pm/functions
>       215 # reload all the modules in no particular order.
>       216 modreload()
>       217 {
>       218       for x in /var/run/pm-suspend/module:* ; do
>       219               [ -f "${x}" ] && modprobe "${x##*:}" >/dev/null 2>&1
>       220       done
>       221 }
> Here it would be a little nice to have the nullglob feature, too. Also I like
> speaking variable names for than "x", e.g. "module".

Yeah, having nullglob wold be nice, but it is not POSIX, so...

> Regards,
> Till

Thanks for the feedback!

-- 
Victor Lowther
Uubntu Certified Professional


More information about the Pm-utils mailing list