up. String without shebang returns 0 for pgrep -c $0 or 1 for ps aux | grep -c $0. Solved with help of user Valrust from forum.ubuntu.ru, it's standart behavior of the system. In that case new copy of script runs as "bash" without agruments and try to find /address/name.sh in ps aux returns nothing, but pgrep -c bash returns more and more values depends from run copies.
-- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to bash in Ubuntu. https://bugs.launchpad.net/bugs/1958060 Title: bash returns wrong variable value/call more proccesses? Status in bash package in Ubuntu: New 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-apple-darwin21.1.0) GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu) 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.3-7ubuntu1.8+esm1 0 -32768 https://esm.ubuntu.com/ubuntu/ trusty-infra-security/main i386 Packages *** 4.3-7ubuntu1.7 0 500 http://ru.archive.ubuntu.com/ubuntu/ trusty-updates/main i386 Packages 500 http://security.ubuntu.com/ubuntu/ trusty-security/main i386 Packages 100 /var/lib/dpkg/status 4.3-6ubuntu1 0 500 http://ru.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1958060/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp