bash returns wrong variable value/call more proccesses?
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
Simple function gives different results when interpretator set in first string of script
CHECKPROC()
{
i=$(ps aux | grep -c $0)
ps aux | grep -c $0
echo variable is $i
sleep 10
}
CHECKPROC
Expected
In any conditions it will return same values, then will increments when other copies of script will be found in proccesses list.
Happened.
We set interpretator with #!/bin/bash or #!/bin/sh in first string of script and runs multiple copies of script from one terminal with & after scriptname. It's returns "1" and "variable is 1" always.
Without interpretator setup, when string #!/bin/bash or #!/bin/sh deleted.
Run multiple copies scriptname.sh&
On every iteration it returns right first value and "variable is $value+1"
$scriptname.sh&
2
variable is 3
$scriptname.sh&
3
variable is 4
...and so on.
Without counting in first case it returns only string with grep, in second case -- one more string with different PID and script name when called from i=$(...) or i=`...`
Ubuntu 14.04 x32, bash 4.3.11(1)-release
Same results from other man on
GNU bash, version 5.1.16(1)-release (aarch64-
GNU bash, version 4.4.20(1)-release (x86_64-
lsb_release -rd
Description: Ubuntu 14.04.6 LTS
Release: 14.04
apt-cache policy bash
bash:
Установлен: 4.3-7ubuntu1.7
Кандидат: 4.3-7ubuntu1.7
Таблица версий:
4.
-32768 https:/
*** 4.3-7ubuntu1.7 0
500 http://
500 http://
100 /var/lib/
4.3-6ubuntu1 0
500 http://
affects: | ubuntu → bash (Ubuntu) |
Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https:/ /wiki.ubuntu. com/Bugs/ FindRightPackag e. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.
To change the source package that this bug is filed about visit https:/ /bugs.launchpad .net/ubuntu/ +bug/1958060/ +editstatus and add the package name in the text box next to the word Package.
[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]