On Thu, 2 Jun 2022 16:23:01 -0500, Erik Janssen wrote:
>Not sure if the ! can be escaped in any way, but I saw it is possible to set
>another character in the options as the pathname substitution character.
>
I dislike alternative metacharacters. They require that I select characters
that I expect not to use in actual code yet easily accessible on a keyboard.
Escapes are more general, as in:
1035 $ echo foo | sed -E s/foo/" \\( ; \\) ! \\/ \" ' "/
( ; ) ! / " '
Imagine the analogue in ISPF Edit:
Chhange c'foo' ?????
The only way to code the replacement is as a hex string. Ugh!
>In my case I would definitately prefer to use an ssh session or the omvs
>shell, but I was looking if there were options for users that have less
>experience with unix to still be able to give commands this way.
>
That's valid only if those users need only your script; never other shell
commands. Otherwise they're better off learning whatever UNIX they
need, not a transcription into ISPF jargon.
>I also found out that you can use dirname and basename to get the directory
>name and filename portion of the path.
>cd `dirname !`;pwd;basename !;
>
Here, I'll advocate not a substitution character but an environment varable,
e.g. ISPPATH (assuming $ISP is a reserved prefix.) then your command
can use shell intrinsics:
cd "${ISPPATH%/*}"; pwd; "${ISPPATH##*/}"
which fanatics advocate for performance. It avoids two forks.
(I usually code "cd "whatever" || exit $?" -- never trust my caller.
--
gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN