Re: [dev] wmii: dash, bash and tests in wmiirc

From: Kris Maglione <maglione.k_AT_gmail.com>
Date: Sun, 18 Jul 2010 21:30:19 -0400

On Mon, Jul 19, 2010 at 02:43:22AM +0200, LuX wrote:
>I am puzzled at the moment by the following problem. I would like to
>list a part of the content of a directory (in /dev/disk/by-id, list
>all the files whose name starts with 'usb') and make a test on this
>list in order to perform some actions. For some reasons which I do not
>understand, the result of the test is not correct when called by
>wmiirc, although the same test and commands work pretty well when
>executed in a dash shell, or when wmiirc calls an external bash (but
>not a dash) script in order to perform them.

Hi,

First of all, you're making things too complicated. The
following would suffice:

AAA() {
     for i in $HOME/.wmii/*; do
         j=${i##*/}
         if wmiir ls /rbar/test-$j >/dev/null 2>&1; then
         # or:
        # wmiir ls /rbar | grep test-$j >/dev/null; then
             echo -n "$WMII_FOCUSCOLORS $j" | wmiir create /rbar/test-$j
             sleep 1
             wmiir remove /rbar/test-$j
         fi
     done
}

Second, your problem is that wmiirc disables globbing. This is
also the problem with your bbb script. You have the -f flag in
the shebang line when you run dash, but not bash. If you want it
to work, either add 'local set +f' to the function or ls the
directory rather than globbing its contents.

P.S. We use context (unified) diffs on this list.

-- 
Kris Maglione
UNIX was not designed to stop its users from doing stupid things, as
that would also stop them from doing clever things.
	--Doug Gwyn
Received on Mon Jul 19 2010 - 03:30:19 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 19 2010 - 03:36:02 CEST