Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR files here"

28 views
Skip to first unread message

Hongyi Zhao

unread,
Jun 15, 2015, 1:06:49 AM6/15/15
to
Hi all,

What's the mean for using `!' in echo, say, for the following example:

echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR
files here"

You can find the command from here:

http://139.179.64.2/mt2/SIESTA-PHON/PHON/1_SCRIPTS/phon_input

Regards
--
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Janis Papanagnou

unread,
Jun 15, 2015, 1:47:44 AM6/15/15
to
On 15.06.2015 07:06, Hongyi Zhao wrote:
> Hi all,
>
> What's the mean for using `!' in echo, say, for the following example:
>
> echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR
> files here"

The same meaning as the word "Please": a plain text. Repeated four times
to draw attention.

I suppose you are maybe still using bash and are wondering about errors
or strange output you see? - Change your shell, use ksh, if you don't
want your quoted literal "!" in text be interpreted, or change all your
programs to use single quotes in strings where you intend to use this
normal character "!" in your texts. (Or read the manual; there might be
an option to disable this IMO broken default behaviour in bash.)

Janis

Chris F.A. Johnson

unread,
Jun 15, 2015, 2:08:06 AM6/15/15
to
On 2015-06-15, Hongyi Zhao wrote:
> Hi all,
>
> What's the mean for using `!' in echo, say, for the following example:
>
> echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR
> files here"

It prints an exclamation mark. What else would you expect?

At the command line, however, if you are unfortunate enough to have
one in $histchars, it does all sorts of weird things. Remove it at
once! Put this in your .bashrc:

histchars=${histchars/!/}

Or, at the command line:

unset histchars


--
Chris F.A. Johnson

Janis Papanagnou

unread,
Jun 15, 2015, 3:06:12 AM6/15/15
to
On 15.06.2015 07:22, Chris F.A. Johnson wrote:
> On 2015-06-15, Hongyi Zhao wrote:
>> Hi all,
>>
>> What's the mean for using `!' in echo, say, for the following example:
>>
>> echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR
>> files here"
>
> It prints an exclamation mark. What else would you expect?
>
> At the command line, however, if you are unfortunate enough to have
> one in $histchars, it does all sorts of weird things. Remove it at
> once! Put this in your .bashrc:
>
> histchars=${histchars/!/}

That's ineffective if histchars is empty (or not defined).

>
> Or, at the command line:
>
> unset histchars

Also ineffective in my environment.

I'm running GNU bash, version 4.2.25

Janis

Hongyi Zhao

unread,
Jun 15, 2015, 5:11:17 AM6/15/15
to
On Mon, 15 Jun 2015 07:47:41 +0200, Janis Papanagnou wrote:

> I suppose you are maybe still using bash and are wondering about errors
> or strange output you see?

Yes.

> - Change your shell, use ksh,

I'll give it a try.

> if you don't
> want your quoted literal "!" in text be interpreted, or change all your
> programs to use single quotes in strings where you intend to use this
> normal character "!" in your texts. (Or read the manual; there might be
> an option to disable this IMO broken default behaviour in bash.)

See the strange output for my case:

werner@debian:~$ echo "!"
bash: !: event not found
werner@debian:~$ echo "!!"
echo "gedit "
gedit
werner@debian:~$ echo "!!!"
bash: !": event not found
werner@debian:~$ echo "!!!!"
echo "echo "gedit "echo "gedit ""
echo gedit echo gedit
werner@debian:~$

Janis Papanagnou

unread,
Jun 15, 2015, 7:11:40 AM6/15/15
to
On 15.06.2015 11:11, Hongyi Zhao wrote:
> On Mon, 15 Jun 2015 07:47:41 +0200, Janis Papanagnou wrote:
>
>> I suppose you are maybe still using bash and are wondering about errors
>> or strange output you see?
>
> Yes.
>
>> - Change your shell, use ksh,
>
> I'll give it a try.
>
>> if you don't
>> want your quoted literal "!" in text be interpreted, or change all your
>> programs to use single quotes in strings where you intend to use this
>> normal character "!" in your texts. (Or read the manual; there might be
>> an option to disable this IMO broken default behaviour in bash.)
>
> See the strange output for my case:

You may have missed that part: "[...] use *single* quotes [...]"

Huibert Bol

unread,
Jun 15, 2015, 11:08:15 AM6/15/15
to
That is to be expected with history substitutions enabled, you can
easily turn it of: set +H

--
Huibert
"Okay... really not something I needed to see." --Raven

Chris F.A. Johnson

unread,
Jun 15, 2015, 5:08:06 PM6/15/15
to
On 2015-06-15, Janis Papanagnou wrote:
> On 15.06.2015 07:22, Chris F.A. Johnson wrote:
>> On 2015-06-15, Hongyi Zhao wrote:
>>> Hi all,
>>>
>>> What's the mean for using `!' in echo, say, for the following example:
>>>
>>> echo "!!!! Please make sure that you put INPUT.fdf, *.psf and POSCAR
>>> files here"
>>
>> It prints an exclamation mark. What else would you expect?
>>
>> At the command line, however, if you are unfortunate enough to have
>> one in $histchars, it does all sorts of weird things. Remove it at
>> once! Put this in your .bashrc:
>>
>> histchars=${histchars/!/}
>
> That's ineffective if histchars is empty (or not defined).

If histchars is empty or not defined, then there's no problem to be solved.

--
Chris F.A. Johnson

Stephane Chazelas

unread,
Jun 15, 2015, 5:50:09 PM6/15/15
to
2015-06-15 16:18:45 -0400, Chris F.A. Johnson:
$ bash --norc
bash-4.3$ echo "${histchars-unset}"
unset
bash-4.3$ echo "!!"
echo "echo "${histchars-unset}""
echo unset
bash-4.3$ histchars=${histchars/!/}
bash: !/}: event not found
bash-4.3$ histchars=${histchars/\!/}
bash-4.3$ echo "!!"
!!

So looks like the "problem" is when $histchars is unset (like it
is by default) and setting histchars to the empty string fixes
the "problem".

--
Stephane

Eric

unread,
Jun 15, 2015, 6:10:05 PM6/15/15
to
Well...

eric@bruno [ ~ ]$ set | grep histchars
eric@bruno [ ~ ]$ !!
set | grep histchars
eric@bruno [ ~ ]$ histchars=""
eric@bruno [ ~ ]$ set | grep histchars
histchars=
eric@bruno [ ~ ]$ !!
-bash: !!: command not found
eric@bruno [ ~ ]$

So apparently it defaults if not defined, but if set to the empty
string, nothing happens. Of course there are some bash options that
might change this.

Eric
--
ms fnd in a lbry

Janis Papanagnou

unread,
Jun 16, 2015, 1:27:48 AM6/16/15
to
There is! - echo $histchars provides an empty result per default.
Still the problem exists. As said, unset'ing also doesn't help.
As others pointed out, setting it explicitly to a null-string
seems to fix that issue.

Janis

0 new messages