scheme shell
about
download
support
resources
docu
links
 
scsh.net
From: gasbichl@informatik.uni-tuebingen.de (Martin Gasbichler)
Newsgroups: comp.lang.scheme.scsh
Subject: Re: Using a bash script as command interpreter?
Message-ID: <vya662a4uzd.fsf@aubisque.informatik.uni-tuebingen.de>
Date: Mon, 29 Apr 2002 13:14:46 +0200

>>>>> "Robert" == Robert Morelli <morelli@math.utah.edu> writes:

Robert> I'm using scsh for some of my scripts but since it's not installed on 
Robert> my facility,  I have it in my home directory.  However,  I need binaries 
Robert> for several architectures,  so I tried using a script "scshswitch" as 
Robert> follows as the command interpreter:

Robert> --------------------------------------------------
Robert> #!/usr/local/bin/bash
Robert> echo "arg is" $1
Robert> if [ `uname` = "FreeBSD" ]; then
>> /home/morelli/bin/freebsd_x86/bin/scsh -s $1
Robert> elif [ `uname` = "SunOS" ]; then
>> /home/morelli/bin/SunOS/bin/scsh -s $1
Robert> elif [ `uname` = "Linux" ]; then
>> /home/morelli/bin/Linux/bin/scsh -s $1
Robert> fi
Robert> --------------------------------------------------

Robert> This script is supposed to check what operating system is running and
Robert> hand a scsh script to the appropriate binary.  

Robert> However,  this doesn't work.  For instance,  I have a
Robert> script "hello" as follows
Robert> --------------------------------------------------
Robert> #!/home/morelli/bin/scshswitch
Robert> !#

Robert> (display "Hello World\n")
Robert> --------------------------------------------------

Robert> Note that this file lists scshswitch as its command interpreter rather 
Robert> than scsh.

Robert> If I enter
Robert> schswitch hello
Robert> then the script hello executes properly,  outputting "Hello World."
Robert> However,  when I try to run the script directly with
Robert> hello
Robert> I get the following output:

Robert> /home/robert/bin/scsh/hello
Robert> /home/robert/bin/scsh/hello: !#: command not found
Robert> display: Unable to open file (Hello World\n) [No such file or directory].

Robert> At this point,  Image Magick loads.  Image Magick is invoked with the
Robert> command "display."  Clearly,  bash,  not scsh,  is trying to execute the 
Robert> script.

Robert> Can anyone explain this?

The #! trigger is not recursive: You cannot specify a script
there. See also the comments in scsh/scsh-tramp.c.

Another way to write "portable" scripts is to take care that the right
executable is in your path and use a header like this:

#!/bin/sh
IFS=" "
exec scsh -s "$0" "$@"
!#
;;; your scsh code goes here...


You may also want to read the discussion archive for SRFI 22,
available at http://srfi.schemers.org/srfi-22/mail-archive/maillist.html

-- 
Martin

Up