-1

In shell script in the middle there is one function as

#!/bin/ksh
 
var=$?
.......
FILE_NAME="/dir/user/work/file/abc.txt"
. ${FILE_NAME}
. ${HOME_PATH}/script/abc.sh

.....

func_start() {
JOB_ID=$1
FLAG=$2
NODES=$3

while [$i -le $NODES]

........ }

exit 0

What does it mean here in this script as var=$?, . ${file name} & function func_start() job_id=$1 flag=$2 nodes=$3? I am not much clear about this.

user8487380
  • 156
  • 3
  • 18
  • Note that "please explain this code" questions should be narrow and specific. Asking what four different things mean generally should be the topic of four different questions -- and if you _are_ asking as four different questions, you could find duplicates of all of them previously asked and answered in our knowledge base. – Charles Duffy Dec 12 '22 at 18:37
  • 1
    Also, http://shellcheck.net/ will automatically point out some obvious problems here (one of those problems is writing `[$i -le $NODES]` instead of `[ "$i" -le "$NODES" ]` -- the spaces and quotes are all important). – Charles Duffy Dec 12 '22 at 18:38

1 Answers1

-2

$? returns the exit value of the last executed command. echo $? prints that value on console. zero implies a successful execution while non-zero values are mapped to various reason for failure.

$1 $2 $3 : according to GNU

A positional parameter is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell’s arguments when it is invoked, and may be reassigned using the set builtin command.

user23
  • 41
  • 7
  • Please don't answer obvious duplicates; see the _Answer Well-Asked Questions_ section of [How to Answer](https://stackoverflow.com/help/how-to-answer), and the bullet point therein regarding questions that "have been asked and answered many times before". – Charles Duffy Dec 12 '22 at 18:36
  • @jignesh even i also know about these concepts. – user8487380 Dec 12 '22 at 18:38