Strange third argument in shell function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange third argument in shell function
# 1  
Old 07-25-2017
Strange third argument in shell function

In one of my shell function I found the following

Code:
 set_default_values () {
         prog=$1
        PROC_DT=$2
        RESET_ALL="${3-N}"
        #echo "Processing date as passed = [$2], Program name = [$1]"
......

I understand the first and second arguments, but don't understand what is
Code:
 RESET_ALL="${3-N}"

I know that I send only two arguments, why do I need third? If I don't send it. And why is it strange N letter? The code is very old and I am converting it to Perl now

Thanks for contribution
# 2  
Old 07-25-2017
It becomes N whenever its empty, so by not giving a third argument, you are setting RESET_ALL to N.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strange function call in the shell script parse_prog_args $@

I am converting shell script to Perl. In shell I have a code parse_prog_args() { if then while do case $1 in -P* | -p* ) export PROCESS_DATE=$2 export MM=`echo $2 | cut -c5-6` export DD=`echo $2 | cut -c7-8` export YY=`echo $2 | cut -c3-4` export... (4 Replies)
Discussion started by: digioleg54
4 Replies

2. Shell Programming and Scripting

passing argument from one function to another

Hi all, In the given script code . I want to pass the maximum value that variable "i" will have in function DivideJobs () to variable $max of function SubmitCondorJob(). Any help? Thanks #!/bin/bash ... (55 Replies)
Discussion started by: nrjrasaxena
55 Replies

3. Shell Programming and Scripting

pass function as argument to a function

I have the following code : function1 () { print "January" } function2() { case $1 in January) print "Dzisiaj mamy styczen" ;; *) ;; } main() { (1 Reply)
Discussion started by: presul
1 Replies

4. Shell Programming and Scripting

Passing commandline argument to a function

Hi, I have 2 ksh scripts. Script1.ksh contains function definition. script1.ksh function f1() { while getopts a:c: args do case $args in a) ARG1=$OPTARG ;; c) ARG2=$OPTARG ;; \?) echo "Error no valid Arguments passed" esac done echo $ARG1 echo $ARG2 script2.sh (2 Replies)
Discussion started by: siba.s.nayak
2 Replies

5. Shell Programming and Scripting

Passing more than one argument in a function

Hi All, Calling a function with one argument and storing the return value in a shell script is as below:( so far I know) value="`fun_1 "argument1"`" Its working perfectly for me. Can u help me with passing more than one argument and storing the return value Thnaks in advance JS (1 Reply)
Discussion started by: jisha
1 Replies

6. Linux

Strange problem with gettimeoftheday function

Hi all, I am using pthread_cond_timedwait function in my program, to generate the time period of waiting i use gettimeoftheday function. When i run the code after compiling i get a core dump error. However my program runs perfectly if i give a printf statement before the gettimeoftheday... (1 Reply)
Discussion started by: xyz123456
1 Replies

7. Shell Programming and Scripting

Very strange things happened in the shell function

Here is the script: #!/bin/bash #set -xv RAWDATAFILE="temp1" GOODDATAFILE="temp2" FindSOS() { local NUM=0 #return value for the id of SOS local cnt=1 if grep "EOS" $1 then sed -e 's/.*<CobDate>//' -e 's/<\/.*//' <$1 > ${RAWDATAFILE} sed -n -e '/EOS/,/SOS/ s/*/&/p' <${RAWDATAFILE}... (2 Replies)
Discussion started by: tpltp
2 Replies

8. UNIX for Dummies Questions & Answers

Pass argument to function

Hi, Can someone please explain to me how I can get a function to recognize a file given as an argument to a script. Suppose the script has the argument as follows: sh script file and the function is as follows: function display_file () { cat $1 } and it s then called #main program... (1 Reply)
Discussion started by: Knotty
1 Replies

9. Shell Programming and Scripting

shell: creating different arrays based on function argument

hi, I was wondering if there was a good way to create an array within a function, where the name is based on a passed argument? I tried this: _____________________________ func(){ #take in 1st arg as the arrayname arrayName=$1 let i=0 while read line do arrayName=${line} let i+=1... (5 Replies)
Discussion started by: nix21
5 Replies

10. UNIX for Dummies Questions & Answers

Passing Argument to Function

May i know how to pass an argument to a function in a shell script? Sorry, i din stated that it is in a shell script in my previous post. Means: checkStatus() { ........... } read status; I wanna use the status in the function checkstatus, how... (2 Replies)
Discussion started by: AkumaTay
2 Replies
Login or Register to Ask a Question