[X-Unix] Hiding apps from the command line

Stroller MacMonster at myrealbox.com
Fri Mar 26 09:05:10 PST 2004


On Mar 26, 2004, at 1:59 pm, Eugene Lee wrote:
>
> # This script lets you hide a specified application, the Finder, all
> # applications but the Finder, or all applications other than a 
> specified
> # application.
> # Syntax is as follows:
> #
> # hide o [appname] - hides all other apps
> # hide a           - hides all apps but Finder
> # hide f           - hides Finder
> # hide [appname]   - hides specified app
> # hide v [appname] - shows specified app
> # hide t           - shows all apps

You're missing an flag. You either need a flag for "hide" (the same as 
running the command without a flag) or you need a flag to specify that 
the next argument is the app name. Otherwise someone will, eventually, 
discover that the command is unable to hide an app named o (or -o, as 
the cae may be).

Also, if you're going to use $1 ...$9... as variables in your script, 
it's also worth including this line in the script before you do so:
  if [ -z "$1" ]
   then
     echo "ERROR! This script requires a commandline argument, silly!" 
 >&2
     exit 1
   fi

>     if "$1" is "a"
>         set visible of every process whose visible is true and name is 
> not "Finder" and name is not "$1" to false
>     else if "$1" is "f"
>         set visible of application process "Finder" to false
>     else if "$1" is "o"
>         set visible of every process whose visible is true and name is 
> not "$2" to false
>     else if "$1" is "t"
>         set visible of every process whose visible is false to true
>     else if exists application process "$1"
>         set visible of application process "$1" to false
>     end if

I'd say there's a good case for a case statement here, haw haw..!

Also, check out the `getopts` construct on pages 138 - 139 of the 
Advanced Bash−Scripting Guide (free download from the LDP).

Stroller.



More information about the X-Unix mailing list