[prog] check if script parent process is "init"

Riccarda Cassini riccarda.cassini at gmx.de
Wed Apr 21 11:31:30 EST 2004

John Clarke wrote:
> On Wed, Apr 21, 2004 at 08:35:35AM +0200, dominik schramm wrote:
> > $ cat caller.sh
> > #!/bin/sh
> > . callee
> > 
> > $ cat callee
> > #!/bin/bash
> > # contains bash specific syntax
> > ...
> > My thought was that this couldn't work.
> It'll work fine, because the kernel uses the first line of the script
> (the part after "#!") to find the handler.  caller.sh can only contain
> sh commands because it's being run by /bin/sh, but callee is being run
> by /bin/bash so it can include anything that bash understands. 

(sorry for jumping in on your thread, Dominik)

I'm not sure I understand. I thought the point Dominik was trying to
make was about *sourcing* the script, and that commands in the sourced
file have to be understood by the interpreter that sources the file.

Just tried it with bash + perl:

  . ./sourced.pl
  echo "done."

with "sourced.pl" being:


  print "in perl\n";

When I try to run this, I get:

  ./test.sh: print: command not found

Doesn't this mean that the shell cannot handle perl's print command?

(Mind you, I just began to do some serious shell programming, only a
couple of days ago, so I could be misunderstanding something
completely...  no flames please :-)


NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/dsl

More information about the Programming mailing list