gnu-arch-users
[Top][All Lists]
Advanced

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

Re: [Gnu-arch-users] Convenience shell macros


From: Jan Hudec
Subject: Re: [Gnu-arch-users] Convenience shell macros
Date: Sun, 1 Feb 2004 15:01:31 +0100
User-agent: Mutt/1.5.5.1+cvs20040105i

On Sun, Feb 01, 2004 at 10:58:02 +1100, Brian May wrote:
> trd()
> {
>         rm $1/.arch-ids/\=id &&
>         rmdir $1/.arch-ids &&
>         rmdir $1
> }

Off the top of my head (not testing it):
trd() {
    if [ -r "$1/.arch-ids/=id" ]; then
        ID=$(cat "$1/.arch-ids/=id")
        rm "$1/.arch-ids/=id" &&
            rmdir "$1/.arch-ids" &&
            rmdir "$1" ||
          tla add --id "$ID" "$1"
    else
        rmdir "$1"
    fi
}

Note: This way it should be for POSIX shell (IIRC the { is required on
the same line as function name and quotes protect against
double-expansion). I have not tried it though.

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec 
<address@hidden>




reply via email to

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