Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

function in shell script returning 0 only

lockdir="somedir"
testlock(){
    retval=""
    if mkdir "$lockdir"
    then # Directory did not exist, but it was created successfully
         echo >&2 "successfully acquired lock: $lockdir"
         retval="true"
    else
         echo >&2 "cannot acquire lock, giving up on $lockdir"
         retval="false"
    fi
    echo "$retval"
}

retval=$( testlock )
if [ "$retval" == "true" ]
then
     echo "directory not created"
else
     echo "directory already created"
fi
Comment

PREVIOUS NEXT
Code Example
Shell :: install react-livechat 
Shell :: linux mount lvm 
Shell :: when-i-start-ubuntu-it-enters-tty1-6-instead-of-my-desktop-how-do-i-get-to-de/65234#65234 
Shell :: bash check other instances 
Shell :: best garuda linux version 
Shell :: pip install SSLComerz 
Shell :: from one terminal tab to another linux 
Shell :: ansible how to install apache on a remote machine 
Shell :: watch bash second 
Shell :: How install CoolTerm on Linux? 
Shell :: allocate gpu in hpc slurm 
Shell :: iis restart command promt 
Shell :: How to determine if CPU VT extensions are enabled in bios? 
Shell :: powershell check end of string 
Shell :: install slurm debian 
Shell :: cscp from remote server to windows subsystem 
Shell :: set windows transaparancy linux 
Shell :: linux high load send mail 
Shell :: github.com developer 
Shell :: how to install ruby on rails with curl 
Shell :: half life duckroll script 
Shell :: change nmp proxy password 
Shell :: install webex with wine 
Shell :: i want to change my heroku app name after it has been deployed 
Shell :: Terabyte 
Shell :: gitlab stale branches api script 
Shell :: bash expect not working in crontab 
Shell :: the http //repo.packagist.org/p/illuminate/ coud not download 
Shell :: how to print the number of columns in your terminal using tput in linux 
Shell :: how to remove duplicate packages 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =