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

Re: Parameter subsitution



On Fri, Jan 8, 2021 at 2:02 PM Lewis Butler <lbutler@xxxxxxxxxx> wrote:
>
> The s/l/r/ substitution works as follows.
>  [. . . ]
> * A null l uses the previous string either from the previous l or from the contextual scan string s from ‘!?s’.
> * Note the same record of the last l and r is maintained across all forms of expansion.
>
> Does this mean that l is recorded until the shell terminates or until a new l is used?

Until a new l is used.

> Is there a way to see what the current l is set to?

No.

> $ file="/usr/local/tmp/filename.txt"
> $ echo ${file:s|e|3}
> /usr/local/tmp/fil3name.txt
> $ echo ${file:s||4}
> /usr/local/tmp/filename.txt
>
> Doesn't look like the l is maintained?

Works for me:

ubuntu% file=filename
ubuntu% print ${file:s/e/3}
fil3name
ubuntu% print ${file:s//4}
fil4name
ubuntu% print ${file:s||5}
fil5name
ubuntu%

> And where is the !?s syntax defined?

History expansion, under Event Designators.

> Any examples of using !?s in anger?

What are you talking about!?




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