« first day (32 days earlier)      last day (2367 days later) » 

4:47 PM
I was hoping that last directory question would get a python answer
not seem much of Jacob or Serg these days
 
It seems like the sort of thing that shells are good for.
But it's just so much simpler and easier with Python than any shell technique I can think of, except really hacky techniques that make more directories than needed and then remove some.
So the thing about quotes inside and outside of a command substitution not interacting with one another (from a comment on your answer) got me thinking.
It is a bug that, in Bash, echo $(echo '!') does not trigger history interaction, but echo "$(echo '!')" does?
 
how can you tell that it does?
 
Do you have history interaction enabled?
If so, you should be able to tell just by running both commands.
 
what have I done to my bash?
 
With what?
Those commands should not harm anything.
What happened?
What does echo "$-" output?
 
5:07 PM
$ echo "$-"
himBHs
 
That looks like history interaction is on, since you have H.
What do you get when you run echo hello followed by echo !!?
 
same as usual
$ echo hi
hi
zanna@toaster:~$ !!
echo hi
hi
oh no that's not what you said... this is what I already did
 
Huh. Maybe the behavior I've observed really is a bug, and was fixed.
 
zanna@toaster:~$ echo hello
hello
zanna@toaster:~$ echo !!
echo echo hello
echo hello
 
Well that's just as good though, I just wanted to know if ! was ever treated specially.
 
5:13 PM
yeah
 
What version of Bash do you have, on what OS?
 
GNU bash, version 4.4.7(1)-release (x86_64-pc-linux-gnu)
Ubuntu MATE 17.04
 
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Lubuntu 16.04 LTS
 
hmm. I have a 16.04
 
That's probably why. Bash on my Windows system with MSYS2 (not WSL) doesn't have history interaction from either command. It has:
GNU bash, version 4.4.12(1)-release (x86_64-pc-msys)
What version of Bash do you have on your 16.04 system and does it behave the same or different?
 
5:21 PM
just booting it to find out
same version as you
$ echo "$(echo '!')"
echo "$(echo '' {} \;)"
{} ;
that's odd...
 
That is odd, because what's !'?
What I get, I can at least explain.
ek@Io:~$ echo $(echo '!')
!
ek@Io:~$ echo "$(echo '!')"
-bash: !': event not found
 
well that's the strangest part...
zanna@xubi:~$ bash -version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
zanna@xubi:~$ echo "$(echo '!')"
echo "$(echo '' {} \;)"
 {} ;
zanna@xubi:~$ echo $(echo '!')
!
zanna@xubi:~$ echo foo
foo
zanna@xubi:~$ echo "$(echo '!')"
echo "$(echo '' {} \;)"
 
It looks like it's from a find command with the -exec or -execdir action. Is there anything in the output of history that explains it?
Still, I don't see anything in the documentation about !' meaning anything.
 
oh yeah, looks like item 79
 
But why would that item be selected specifically?
 
5:36 PM
it makes no sense
 
What happens when you try it while logged in as another user?
 
pixie@xubi:/home/zanna$ echo "$(echo '!')"
bash: !': event not found
 
That's what I get.
 
yeah
 
So how is a !' event found ever?
 
5:39 PM
maybe it finds a command starting with '
 
Or, wait.
Yeah.
Yeah, that's it. Because ' is not performing quoting, it is not treated specially, and apparently it can work the same as a letter, which I had not known.
Does that item in your history actually start with '?
 
yeah
 
That fully explains it then.
So is the older Bash behavior seen on 16.04 a bug?
 
$ !79
' {} \;
>
why does it happen? does the first single quote turn off quoting?
 
Huh, I just noticed the Bash documentation has stopped calling it "history interaction" and started calling it "history expansion." I remember the terminology in that answer was in line with the linked page when the answer was first posted.
@Zanna I believe history expansion (I'm going back to calling it that!) takes place early in parsing.
 
5:52 PM
$ echo "$(echo '!')"
echo "$(echo '' {} \;)"
++ echo '' '{}' ';'
+ echo ' {} ;'
 {} ;
It seems pretty weird that the expansion (it's much more intuitive to call it that) isn't suppressed there when it is without the double quotes
 
I think what is happening is that history expansion takes place before the special meaning of $ or ` has taken effect.
So the parser doesn't know the ' ' are inside a command substitution.
So it treats the ! inside them literally.
 
the quotes are quoted
I got it
 
But when the ' ' appear inside " ", their special meaning is removed, so they cannot remove the special meaning of !.
Yeah.
So then it seems like the bug would be that it doesn't perform history expansion in both cases.
Yet in newer versions of Bash, neither does. Does history expansion just never take place inside command substitution, now?
On my 16.04 system, echo "$(echo !!)" (with or without the " ") performs history expansion. Does that happen on your 17.04 system?
 
yeah
$ echo $(echo !!)
echo $(echo uname -r)
uname -r
and same with double quotes outside
 
But history expansion takes place in the current (outer) shell, not in the subshell. So why does the outer shell treat quotes specially inside the command substitution?
Is the new behavior (also?) a bug?
Well, wait.
Knowing what a quote mark does usually requires knowing if it's inside ( ). Never mind, that's only fully true for " " where embedded command substitution happens. For ' it only determines whether you get a secondary prompt.
 
6:08 PM
I'm going to a dance class. Later :)
 
Cya!
 

« first day (32 days earlier)      last day (2367 days later) »