Post subject: Question about shell scripts
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
Hello. So I'm at work trying to figure out some shell scripts. It's fairly simple to read so no problems there. The real mystery I've encountered now is that a test that wasn't working properly suddenly worked when I added this line to it: echo: and I can't for the life of me figure it out. Googling on "echo: " didn't gave anything, so please don't redirect me there :) Anyway, I'm a fairly newbie programmer still but to my understanding echo is just a print out command. But what does the colon do in this case? Does it do anything? I was under the impression that it just ends the line, similiar to ; in other languages. The only reason I can think of why this script suddenly starting to work is that echo: terminates the whole script. But it doesn't make sense either. So, is there anyone who can toss some light on my newbie issue? Thank you very much.
/Walker Boh
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
Depending on the scripting language, "echo:" may be a label, not a command.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
Allright. Not sure if I quite grasp the difference, but at least I have something to work with. Thank you Nach!
/Walker Boh
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
A label is what you use with things like goto, jump, switch. A command could be something internal to the scripting language, or part of the OS. "echo" as a command means print something on the screen.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
Ah, that actually made sense. Thank you very much kind sir. Now only to figure out why the heck it suddenly works.
/Walker Boh
Former player
Joined: 12/1/2007
Posts: 425
man echo. If you want language specific help, you might wanna consider telling us which shell you're talking about.
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
I'd love to, but I have no idea really. Just some sort of shell script that was fairly understandable until I got this weird echo solution. If I learn which one it is I promise to get back to you
/Walker Boh
Joined: 7/2/2007
Posts: 3960
At the command line, do echo $SHELL and it'll tell you what your shell is. We would also be better-able to help you if you pasted your script here.
Pyrel - an open-source rewrite of the Angband roguelike game in Python.
Joined: 9/17/2009
Posts: 18
Location: Hungary
Derakon wrote:
At the command line, do echo $SHELL and it'll tell you what your shell is.
That doesn't work on Windows. ECHO %COMSPEC% has the equivalent effect. In CMD, the command ECHO: has the same effect as ECHO., that is, printing an empty line. Labels in CMD have the colon at the beginning (for example, :ECHO). Bash interprets the colon as part of the file name, so it looks for something named "echo:" which it can't find (unless you make one yourself), so it tells you that the command was not found.
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
Since it's work stuff I'm not sure if I'm allowed to spread the code. Most likely not I'm afraid. I'll keep you updated if I can find something more out. Thanks a bunch for the help in any case! I know I haven't posted much to go on but I'm slowly learning all this new stuff :)
/Walker Boh
Former player
Joined: 4/16/2004
Posts: 1276
Location: Uppsala, Sweden
Just re-read the thread and learned some more stuff about it. Thanks a bunch guys. Of course I forgot to mention that it is makefiles I'm looking at, so the makefile should pass commands to the shell if I got it right. Well, I'll keep looking and learning. Thanks again for the help.
/Walker Boh
arflech
He/Him
Joined: 5/3/2008
Posts: 1120
oh, then I think you just removed some commands from an earlier make target and added a new target "make echo"
i imgur com/QiCaaH8 png