LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   behaviour of echo with ? (the question mark) in gnome-terminal (https://www.linuxquestions.org/questions/programming-9/behaviour-of-echo-with-the-question-mark-in-gnome-terminal-132694/)

fsbooks 01-08-2004 08:14 AM

behaviour of echo with ? (the question mark) in gnome-terminal
 
I have the following script which isolates a problem I have been having:

#!/bin/bash
ps -C sleep -f|tr -s ''|grep sleep|head -n1
ps -C sleep -f|tr -s ''|grep sleep|head -n1|while read rec
do
echo $rec
done
exit

The results differ depending on the gnome-terminal window in which they are started.

Window 1:

$ /tmp/pstest
chris 15214 7874 0 06:43 ? 00:00:00 sleep 3934
chris 15214 7874 0 06:43 ? 00:00:00 sleep 3934
$ echo 06:43 ?
06:43 ?

Window 2:
$ /tmp/pstest
chris 15214 7874 0 06:43 ? 00:00:00 sleep 3934
chris 15214 7874 0 06:43 h m 00:00:00 sleep 3934
$ echo 06:43 ?
06:43 h m

As you can see, it seems to all come down to echo - which somehow decides that in some instances the ? means I need to be told something (that 06 is hours and 43 is minutes) I certainly do not. I am guessing it is some idiotic gnome option that presumes the computer is smarter than I am, since the behaviour differs from window to window (I believe at the moment that new windows give the second wrong result, windows started w/X as part of the session seem to give the first), but certainly shopts are the same in the bash shell.

Just upgraded to fedora core 1 from RH 9.0 with most available updates applied. I have bash-2.05b-34 (GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)). gnome is 2.4 (gnome-terminal-2.4.0.1-1).

fsbooks 01-08-2004 12:41 PM

OK, I figured this out.

It just so happens that I have not been running this program in my $HOME directory. I happen to have a directory called h and one called m in $HOME. A new shell in in $HOME, therefore, echo interpretes the ? as h and m, which I, being "smarter" than the computer, decided was hours and minutes. So I fixed my script and things are cool. Learn something everyday.


All times are GMT -5. The time now is 04:03 PM.