Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: loading user startup files for zsh scripts



On Feb 11,  9:26am, Bart Schaefer wrote:
}
}     print -l -- $(</proc/$$/cmdline)
} 
} But it's true you would then have to skip over shell options to find
} the script name.  I don't suppose anyone out there has written a
} zparseopts spec that matches the zsh invocation-time option set?

Hmm, you really don't need to parse from the left, now that I think on it.

IFS=$'\0' cmdline=( $(</proc/$$/cmdline) )
(( scriptword = $#cmdline - ARGC - 1 ))
if [[ scriptword -gt 1 &&
      opt$cmdline[scriptword-1] != opt-c &&
      -r $cmdline[scriptword] ]]
then print This shell seems to be running script $cmdline[scriptword]
else print This shell does not seem to be running a script
fi



Messages sorted by: Reverse Date, Date, Thread, Author