Discussion:
The angle bracket in an echo command???
(too old to reply)
Muhammad Usman
2023-05-13 06:53:16 UTC
Permalink
I got the solution just after 26 years. Use single quotes such as
echo -e '<!DOCTYPE html>'
will solve the issue.

If we use double quotes, it will surely raise an error.
echo -e "<!DOCTYPE html>"
```bash: !DOCTYPE: event not found```
Kerr-Mudd, John
2023-05-13 08:34:39 UTC
Permalink
On Fri, 12 May 2023 23:53:16 -0700 (PDT)
Post by Muhammad Usman
I got the solution just after 26 years. Use single quotes such as
... and changing OS.
Post by Muhammad Usman
echo -e '<!DOCTYPE html>'
will solve the issue.
If we use double quotes, it will surely raise an error.
echo -e "<!DOCTYPE html>"
```bash: !DOCTYPE: event not found```
DOS: (actually a(n?) XP cmd window)

C:\>echo -e '<!DOCTYPE html>'
The system cannot find the file specified.
--
Bah, and indeed Humbug.
Muhammad Usman
2023-05-13 09:39:58 UTC
Permalink
Post by Kerr-Mudd, John
On Fri, 12 May 2023 23:53:16 -0700 (PDT)
Post by Muhammad Usman
I got the solution just after 26 years. Use single quotes such as
... and changing OS.
Post by Muhammad Usman
echo -e '<!DOCTYPE html>'
will solve the issue.
If we use double quotes, it will surely raise an error.
echo -e "<!DOCTYPE html>"
```bash: !DOCTYPE: event not found```
DOS: (actually a(n?) XP cmd window)
C:\>echo -e '<!DOCTYPE html>'
The system cannot find the file specified.
--
Bah, and indeed Humbug.
I was doing it on bash shell linux. Never tried it on DOS or windows
Kenny McCormack
2023-06-14 19:25:27 UTC
Permalink
Post by Muhammad Usman
Post by Kerr-Mudd, John
On Fri, 12 May 2023 23:53:16 -0700 (PDT)
Post by Muhammad Usman
I got the solution just after 26 years. Use single quotes such as
... and changing OS.
Post by Muhammad Usman
echo -e '<!DOCTYPE html>'
will solve the issue.
If we use double quotes, it will surely raise an error.
echo -e "<!DOCTYPE html>"
```bash: !DOCTYPE: event not found```
...
Post by Muhammad Usman
I was doing it on bash shell linux. Never tried it on DOS or windows
Then you posted to the wrong newsgroup.

Anyway, believe it or not, it is not the angle brackets that are giving you
grief (see below - *); rather, it is the exclamation point (!). You need to
read up on the topic of "history substitution" in "man bash".

(*) Basically, either single or double quotes will protect angle brackets,
but you need single quotes to protect "!".
--
Faith doesn't give you the answers; it just stops you from asking the questions.
Ivan Shmakov
2023-06-15 21:20:42 UTC
Permalink
MU> I got the solution just after 26 years. Use single quotes such as
MU> echo -e '<!DOCTYPE html>'
MU> will solve the issue.

[...]
Post by Kenny McCormack
Anyway, believe it or not, it is not the angle brackets that are
giving you grief (see below - *); rather, it is the exclamation point
(!). You need to read up on the topic of "history substitution" in
"man bash".
(*) Basically, either single or double quotes will protect angle
brackets, but you need single quotes to protect "!".
It's also possible to disable history substitution altogether
with 'set +H'.

I believe this behavior is rather confusing to new users, and
given that C-r (reverse-search-history) and cursor keys already
offer a comparable feature, and one likely to fit better with
user's prior experience at that, my suggestion would be to
have it disabled by default.
--
FSF associate member #7257 http://am-1.org/~ivan/
Kenny McCormack
2023-06-15 21:39:20 UTC
Permalink
In article <u6fvb9$hdk2$***@dont-email.me>,
Ivan Shmakov <***@siamics.netNOSPAM.invalid> wrote:
...
Post by Ivan Shmakov
It's also possible to disable history substitution altogether
with 'set +H'.
I believe this behavior is rather confusing to new users, and
given that C-r (reverse-search-history) and cursor keys already
offer a comparable feature, and one likely to fit better with
user's prior experience at that, my suggestion would be to
have it disabled by default.
I agree. The ! thing was brought over into bash from (t)csh and it is
pretty universally a bad idea. In fact, the rules for how it is handled
are even more confusing in bash than they are in (t)csh. I can never tell
from looking at it whether or not it is going to try to trigger a history
expansion or not.

I may do as you suggest and disable it globally in my bash shells.
--
People sleep peaceably in their beds at night only because rough
men stand ready to do violence on their behalf.

George Orwell
Kaz Kylheku
2023-06-16 00:07:07 UTC
Permalink
Post by Kenny McCormack
...
Post by Ivan Shmakov
It's also possible to disable history substitution altogether
with 'set +H'.
I believe this behavior is rather confusing to new users, and
given that C-r (reverse-search-history) and cursor keys already
offer a comparable feature, and one likely to fit better with
user's prior experience at that, my suggestion would be to
have it disabled by default.
I agree. The ! thing was brought over into bash from (t)csh and it is
pretty universally a bad idea.
Do you remember There was a period in the 1990's when tcsh was widely
used? It was popular among early Linux users, too. I remember
getting a default login shell as tcsh on some systems, having
to change it with chsh.

It hink this was a spill-over effect of csh use on proprietary Unix
systems; people coming from that finding an equivalent in tcsh.

Bash aping some tcsh features (even not so good ones) probably helped
wean people off that.
--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @***@mstdn.ca
Loading...