Re: exec script in all subdirs; pathnames contain spaces



2007-02-21, 15:55(-06), Charles Russell:
[...]
find . -exec sh -c '
unset CDPATH
cd -P "$1" && shift && exec "$@"' inline {} "$@" \;


Sorry, that was not a Bourne shell script. But do you really
need a Bourne shell script? The Bourne shell was common 15 years
ago, but not so much today, and it's not standard as per the new
Unix.

Close enough. It runs on cygwin's ash shell, which is what I normally
use for scripts. The main idea was to be as portable as possible.

I haven't the foggiest notion how your script works, though. Could you
give me some clues where to look for documentation on "inline"? I can't
find it in ash, bash, or find. And what does the final "-" do on line 1
(starting with #!)?

Inline is a "dummy" parameter. You can use anything there.

That parameter will become the inline-script's (the argument to
-c) $0 in POSIX shells.

find . -exec sh -c '
unset CDPATH
cd -P "$0" && exec "$@"' {} "$@" \;

would have been even simpler. It's just that $0 usually contains
the script name, so for inline scripts, I tend to use "inline".

--
Stéphane
.



Relevant Pages

  • Re: Bourne Shell Port Available
    ... >> I guess I'm happy for you, but I spend most of my time on Solaris ... >> boxes trying to avoid the Bourne shell. ... shell script that couldn't be run by ksh anyway. ... > obligation to the POSIX standard requires them to fix non-conforming ...
    (comp.unix.shell)
  • exit call in script causes unit test to not run (newby)
    ... I currently have a ruby script which I'm trying to create some ... If I comment out the exit then my tests actually run. ... something I commonly do in bourne shell scripts and it made sense to ... # Set PROTO constant based on command line arg ...
    (comp.lang.ruby)
  • Re: Help with very basic bourne shell
    ... simple script does not work in bourne shell. ... There is no let command in the Bourne shell; ... This script will be called by a cron job so I don't want any output. ...
    (comp.unix.shell)
  • Re: Bourne shell script affecting current shell with arguments
    ... >We've got a script that is run by users running the Bourne shell to set ... >arguments to this script for the variables to be set. ... Have the script define a function that does the real work. ...
    (comp.unix.shell)
  • Re: DOM doc - simple find element PHP+JS
    ... laoded script seems to work in a skeleton test bed. ... called inline while the page is loading... ... I am running into some problems initializing a decently large search ... but the appendChild() script element does not seem to execute as ...
    (comp.lang.javascript)