Subject: Re: associating(?) .sh scripts
From: David T-G <[email-masked]>
To: "CygWin Users' List" <[email-masked]>
Cc: Andrew Markebo <[email-masked]>
Date: Tue, 4 Jun 2002 19:44:30 -0500

Hi, all --

Sorry I couldn't get to this yesterday...  Anyone remember where we were?  :-)

...and then Andrew Markebo said...
% 
% / David T-G <[email-masked]> wrote:
% | 
% | I have a shell script "meta-play.sh" which I run to collect metadata
% | after I burn an MP3 CD.  I cd into the source directory and run
% | 
% |   ../meta-play.sh cdname
% 
% >From where? The bash script?? command/cmd?? 

From a bash prompt which was fired off directly from a Start menu shortcut
that calls bash.exe.

% 
% What does the first lines of meta-play.sh look like, what about
% dos/unix newlines.. 

When I ran file on it this evening I was surprised to find that it had
CR/LF endings and so I fixed that, but that didn't cut it.

  BASH-2.05a$ ./meta-play.sh
  BASH: ./meta-play.sh: No such file or directory
  BASH-2.05a$ !fil
  file ./meta-play.sh
  ./meta-play.sh: ASCII text
  BASH-2.05a$ head -5 !$
  head ./meta-play.sh

  [ -z "$1" ] && { echo "" ; echo "Whoa; gimma a disc ID like calix-01" ; echo "" ; exit 1 ; }
  n="$1"

  echo ""
  BASH-2.05a$ df -k .
  Filesystem           1k-blocks      Used Available Use% Mounted on
  e:                     2096832    128832   1968000   7% /e
  BASH-2.05a$ mount
  c:\utils\cygwin\bin on /usr/bin type system (binmode)
  c:\utils\cygwin\lib on /usr/lib type system (binmode)
  c:\utils\cygwin on / type system (binmode)
  c: on /c type user (binmode,noumount)
  d: on /d type user (binmode,noumount)
  e: on /e type user (binmode,noumount)

% 
% What does it say if you do 'file meta-play.sh', ls -l of it?

Oh, right.

  BASH-2.05a$ ls -l ./meta-play.sh
  -rw-r--r--    1 david    unknown       907 Jun  4 19:30 ./meta-play.sh

So I tried adding a /bin/sh at the top but that didn't work:

  BASH-2.05a$ head -2 !$
  head -2 ./meta-play.sh
  #!/bin/sh
  [ -z "$1" ] && { echo "" ; echo "Whoa; gimma a disc ID like calix-01" ; echo "" ; exit 1 ; }
  BASH-2.05a$ !$
  ./meta-play.sh
  BASH: ./meta-play.sh: /bin/sh: bad interpreter: No such file or
  directory

So I changed it to bash and finally got somewhere:

  BASH-2.05a$ head -2 ./meta-play.sh
  #!/bin/bash
  [ -z "$1" ] && { echo "" ; echo "Whoa; gimma a disc ID like calix-01" ; echo "" ; exit 1 ; }
  BASH-2.05a$ ./meta-play.sh

  Whoa; gimma a disc ID like calix-01

Great; now we're moving!  Having paid attention over the past few days,
as I write this it occurs to me that perhaps playing with chmod will let
me hit ../m and <tab> when I'm in a CD dir...

Sure enough, a simple a+x does!  I still have to have the shebang line
in there, though, and so I have some other scripts to fix, but I'm on
the way.

Thanks so much, everyone!

HAND

:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) [email-masked] * than to live up to them. -- fortune cookie
(work) [email-masked]
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!