LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-08-2013, 10:03 AM   #1
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Rep: Reputation: 27
Issue: Bash script displays its name upon execution


Hi everyone,
I just noticed a rather annoying issue. Whenever I run a bash script, the first thing that it does is display the name of the script along with all the arguments passed to it (if there are any). However, nowhere in the script there is anything that provokes that behavior.
See for example:
Code:
gacanepa@debian:~/scripts/bash/tests$ ./if_regex.sh 345-14-45
./if_regex.sh 345-14-45
You provided the following argument: 345-14-45
yes
where if_regex.sh is:
Code:
#!/bin/bash
echo "You provided the following argument: $1"
glob="[[:digit:]][[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]-[[:digit:]][[:digit:]]"
if [[ ${1} == $glob ]]; then
    echo "yes"
else
    echo "no"
fi
The same issue happens with other scripts as well . Any ideas as to why this is happening?

Last edited by gacanepa; 07-08-2013 at 10:08 AM.
 
Old 07-08-2013, 10:53 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
I can't replicate your results. I created an if_regex.sh executable file and stuck it in /tmp. I then ran it and here is the outcome:
Code:
tmp$ ./if_regex.sh 345-14-45
You provided the following argument: 345-14-45
yes
The script is copied from yours and pasted into the if_regex.sh that I created in /tmp
There are only two differences:
1. I created the script in /tmp %I can't see that that should matter.
2. I made it executable
Code:
chmod ugoa+x if_regex.sh
Other than that I did everything exactly as you did. Maybe we have a difference in our bash profile file?
A true mystery.
jdk

Last edited by jdkaye; 07-08-2013 at 10:54 AM.
 
1 members found this post helpful.
Old 07-08-2013, 11:00 AM   #3
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Original Poster
Rep: Reputation: 27
Question

Quote:
Originally Posted by jdkaye View Post
I can't replicate your results. I created an if_regex.sh executable file and stuck it in /tmp. I then ran it and here is the outcome:
Code:
tmp$ ./if_regex.sh 345-14-45
You provided the following argument: 345-14-45
yes
The script is copied from yours and pasted into the if_regex.sh that I created in /tmp
There are only two differences:
1. I created the script in /tmp %I can't see that that should matter.
2. I made it executable
Code:
chmod ugoa+x if_regex.sh
Other than that I did everything exactly as you did. Maybe we have a difference in our bash profile file?
A true mystery.
jdk
I actually thought about the bash profile file but the only modification I made to it was setting vim as my default editor. And that was more than a week ago, whereas I just noticed this "issue" earlier this morning (and I've been scripting all along).
 
Old 07-08-2013, 11:16 AM   #4
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by gacanepa View Post
I actually thought about the bash profile file but the only modification I made to it was setting vim as my default editor. And that was more than a week ago, whereas I just noticed this "issue" earlier this morning (and I've been scripting all along).
in Windows (and formerly in DOS) there was an option for the console that would echo every command line after expanding variables, and before executing it. It looks very much like this is what's happening here. Is there a global setting like that for bash? I haven't heard of one yet, but that means nothing ...

[X] Doc CPU
 
1 members found this post helpful.
Old 07-08-2013, 11:20 AM   #5
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Original Poster
Rep: Reputation: 27
Another thing I just noticed. It seems that this is happening not only for scripts but for all commands as well. I just typed
Code:
man bash
and before actually displaying the man page for bash, it showed "man bash" in a separate line and then displayed the man page.
Really weird.
 
Old 07-08-2013, 11:29 AM   #6
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Original Poster
Rep: Reputation: 27
You may not believe this, but I just restarted the server and the issue seems to be gone . Who know what was the cause.
Anyway, I will mark the previous answers as helpful so that it adds to the reputation of everyone who tried to help. I really appreciate it.
 
Old 07-08-2013, 11:33 AM   #7
Z038
Member
 
Registered: Jan 2006
Location: Dallas
Distribution: Slackware
Posts: 910

Rep: Reputation: 174Reputation: 174
What you are describing sounds like you have the bash -v option set.

Check ~/.bashrc, ~/.bash_profile, ~/.bash_login, ~/.profile, /etc/profile, /etc/bash.bashrc and see if you are executing a "set -v" command, or "set -o verbose".

Also, if you issued set -v in a login shell or command window, it would have the same effect.

Last edited by Z038; 07-08-2013 at 11:34 AM.
 
1 members found this post helpful.
Old 07-08-2013, 11:35 AM   #8
gacanepa
Member
 
Registered: May 2012
Location: San Luis, Argentina
Distribution: Debian
Posts: 205

Original Poster
Rep: Reputation: 27
Quote:
Originally Posted by Z038 View Post
What you are describing sounds like you have the bash -v option set.

Check ~/.bashrc, ~/.bash_profile, ~/.bash_login, ~/.profile, /etc/profile, /etc/bash.bashrc and see if you are executing a "set -v" command, or "set -o verbose".

Also, if you issued set -v in a login shell or command window, it would have the same effect.
Thanks!
 
Old 07-08-2013, 02:17 PM   #9
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Quote:
Originally Posted by gacanepa View Post
Anyway, I will mark the previous answers as helpful so that it adds to the reputation of everyone who tried to help. I really appreciate it.
I don't do reputations (mine is irreparably damaged anyway) but if my post was helpful that's reward enough. There is a new moon tonight so that is obviously the reason for this mysterious behaviour.
jdk
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script execution dann_radkov Linux - Newbie 5 10-18-2011 09:46 AM
[SOLVED] Bash script execution error dann_radkov Linux - Newbie 4 09-13-2011 03:15 PM
Issue with remote script execution Orange Sunshine Linux - Newbie 7 05-09-2011 04:54 AM
issue with execution of PERL script rotkmaninov Linux - Software 6 07-10-2008 02:47 PM
BASH: open console on script execution Quis Programming 2 02-07-2006 09:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration