* Parameter subsitution
@ 2021-01-08 22:02 Lewis Butler
2021-01-08 22:25 ` Bart Schaefer
0 siblings, 1 reply; 8+ messages in thread
From: Lewis Butler @ 2021-01-08 22:02 UTC (permalink / raw)
To: Zsh Users
Reading through the docs:
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’.
And
* 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? Is there a way to see what the current l is set to?
$ 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?
And where is the !?s syntax defined?
Any examples of using !?s in anger?
--
ɹןʇnqן
<mailto:lbutler@covisp.net>
tel:+1.303.219.0564
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-08 22:02 Parameter subsitution Lewis Butler
@ 2021-01-08 22:25 ` Bart Schaefer
2021-01-08 22:31 ` Lewis Butler
0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2021-01-08 22:25 UTC (permalink / raw)
To: Lewis Butler; +Cc: Zsh Users
On Fri, Jan 8, 2021 at 2:02 PM Lewis Butler <lbutler@covisp.net> 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!?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-08 22:25 ` Bart Schaefer
@ 2021-01-08 22:31 ` Lewis Butler
2021-01-08 22:53 ` Bart Schaefer
0 siblings, 1 reply; 8+ messages in thread
From: Lewis Butler @ 2021-01-08 22:31 UTC (permalink / raw)
To: Zsh Users
On 08 Jan 2021, at 15:25, Bart Schaefer <schaefer@brasslantern.com> wrote:
>> Any examples of using !?s in anger?
>
> What are you talking about!?
<https://www.ldoceonline.com/dictionary/do-use-something-in-anger>
do/use something in anger
humorous to do or use something in a real situation
--
ɹןʇnqן
<mailto:lbutler@covisp.net>
tel:+1.303.219.0564
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-08 22:31 ` Lewis Butler
@ 2021-01-08 22:53 ` Bart Schaefer
2021-01-08 23:46 ` Lewis Butler
0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2021-01-08 22:53 UTC (permalink / raw)
To: Lewis Butler; +Cc: Zsh Users
On Fri, Jan 8, 2021 at 2:31 PM Lewis Butler <lbutler@covisp.net> wrote:
>
> On 08 Jan 2021, at 15:25, Bart Schaefer <schaefer@brasslantern.com> wrote:
> >> Any examples of using !?s in anger?
> >
> > What are you talking about!?
Obviously my own attempt to be silly went wide of the mark.
> humorous to do or use something in a real situation
% vi foo.c foo.h
... several commands ensue ...
% !?foo.h?:gs/foo/bar
vi bar.c bar.h
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-08 22:53 ` Bart Schaefer
@ 2021-01-08 23:46 ` Lewis Butler
2021-01-09 0:00 ` Lawrence Velázquez
0 siblings, 1 reply; 8+ messages in thread
From: Lewis Butler @ 2021-01-08 23:46 UTC (permalink / raw)
To: Zsh Users
On 08 Jan 2021, at 15:53, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Fri, Jan 8, 2021 at 2:31 PM Lewis Butler <lbutler@covisp.net> wrote:
>>
>> On 08 Jan 2021, at 15:25, Bart Schaefer <schaefer@brasslantern.com> wrote:
>>>> Any examples of using !?s in anger?
>>>
>>> What are you talking about!?
>
> Obviously my own attempt to be silly went wide of the mark.
Text is not always the best medium for silliness 😃
>> humorous to do or use something in a real situation
>
> % vi foo.c foo.h
> ... several commands ensue ...
> % !?foo.h?:gs/foo/bar
> vi bar.c bar.h
Ah, yes, I can see where that would be useful. I often (used to) do things in bash like `^string^replace` (I think that's right) but was frustrated that only replaced the first occurance and only in the previous command, so I got used to using up-arrow to get the command I wanted and then just manually editing.
Wonder why my zsh is not behaving as your with the recalling of l in the substation though.
$ zsh --version
zsh 5.8 (x86_64-apple-darwin20.0)
Maybe something in oh-m-z?
--
ɹןʇnqן
<mailto:lbutler@covisp.net>
tel:+1.303.219.0564
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-08 23:46 ` Lewis Butler
@ 2021-01-09 0:00 ` Lawrence Velázquez
2021-01-09 0:49 ` Bart Schaefer
2021-01-09 1:09 ` Lewis Butler
0 siblings, 2 replies; 8+ messages in thread
From: Lawrence Velázquez @ 2021-01-09 0:00 UTC (permalink / raw)
To: Lewis Butler; +Cc: zsh-users
> On Jan 8, 2021, at 6:46 PM, Lewis Butler <lbutler@covisp.net> wrote:
>
> Ah, yes, I can see where that would be useful. I often (used to)
> do things in bash like `^string^replace` (I think that's right)
Note that zsh recognizes ^foo^bar as well, and bash recognizes !?foo.
> Wonder why my zsh is not behaving as your with the recalling of l
> in the substation though.
>
> $ zsh --version
> zsh 5.8 (x86_64-apple-darwin20.0)
>
> Maybe something in oh-m-z?
Perhaps omz is doing its own history expansions that make using a
null pattern on your command line untenable.
vq
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-09 0:00 ` Lawrence Velázquez
@ 2021-01-09 0:49 ` Bart Schaefer
2021-01-09 1:09 ` Lewis Butler
1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2021-01-09 0:49 UTC (permalink / raw)
To: Lawrence Velázquez; +Cc: Lewis Butler, Zsh Users
On Fri, Jan 8, 2021 at 4:00 PM Lawrence Velázquez <vq@larryv.me> wrote:
>
> > On Jan 8, 2021, at 6:46 PM, Lewis Butler <lbutler@covisp.net> wrote:
> >
> > Wonder why my zsh is not behaving as your with the recalling of l
> > in the substation though.
> >
> > Maybe something in oh-m-z?
>
> Perhaps omz is doing its own history expansions that make using a
> null pattern on your command line untenable.
That was my thought as well. There may be a ${...:s...} in precmd or some such.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Parameter subsitution
2021-01-09 0:00 ` Lawrence Velázquez
2021-01-09 0:49 ` Bart Schaefer
@ 2021-01-09 1:09 ` Lewis Butler
1 sibling, 0 replies; 8+ messages in thread
From: Lewis Butler @ 2021-01-09 1:09 UTC (permalink / raw)
To: zsh-users
On 08 Jan 2021, at 17:00, Lawrence Velázquez <vq@larryv.me> wrote:
>> On Jan 8, 2021, at 6:46 PM, Lewis Butler <lbutler@covisp.net> wrote:
>>
>> Ah, yes, I can see where that would be useful. I often (used to)
>> do things in bash like `^string^replace` (I think that's right)
>
> Note that zsh recognizes ^foo^bar as well,
Yep, but I stopped using it years and years ago, long before I used zsh. Heck, before I used bash4.
> and bash recognizes !?foo.
bash versions greater than 3.x?
But I am not using bash anywhere now other than in some shell scripts that didn't work with zsh and I didn't take the time to figure out why
>> Wonder why my zsh is not behaving as your with the recalling of l
>> in the substation though.
>>
>> $ zsh --version
>> zsh 5.8 (x86_64-apple-darwin20.0)
>>
>> Maybe something in oh-m-z?
>
> Perhaps omz is doing its own history expansions that make using a
> null pattern on your command line untenable.
Probably. I'll test without oh-m-z at some point.
--
ɹןʇnqן
<mailto:lbutler@covisp.net>
tel:+1.303.219.0564
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-01-09 1:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08 22:02 Parameter subsitution Lewis Butler
2021-01-08 22:25 ` Bart Schaefer
2021-01-08 22:31 ` Lewis Butler
2021-01-08 22:53 ` Bart Schaefer
2021-01-08 23:46 ` Lewis Butler
2021-01-09 0:00 ` Lawrence Velázquez
2021-01-09 0:49 ` Bart Schaefer
2021-01-09 1:09 ` Lewis Butler
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).