On Mon, Nov 21, 2005 at 09:34:11AM +0100, Thomas Hood wrote: >Brendan O'Dea wrote: >> Note: I believe that "return" should work to exit from a script both >> when sourced and when executed but perhaps someone with a copy of POSIX >> could confirm. > > >Disconfirmation: > >$ cat /tmp/s >#!/bin/bash >echo foo >return >echo bar >[EMAIL >PROTECTED]:~/src/sysvinit/pkg-sysvinit/sysvinit/trunk/debian/initscripts/etc/init.d$ > /tmp/s >foo >/tmp/s: line 3: return: can only `return' from a function or sourced script >bar
Bleah, I tested with "sh test-script", forgetting that I have sh as an alias for $SHELL (ksh). In which case, what's needed is "return N 2>/dev/null || exit N", which should cover all cases. --bod -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]