#!/bin/sh #notice that the function refers to the positional parameter $1 #the $1 only exists within the function, it does not affect #the $1 from the command line error_fn() { echo "ERROR: $1" echo "ERROR: $2" exit 1 } #here in the function the "you need..." becomes $1 if [ $# -ne 2 ] then echo '$1' from the command line is $1 error_fn "you need at least 2 arguments" "this is the second arg" fi echo "The contents of the first directory you entered are:" ls -l $1 if [ $? -ne 0 ] then echo '$1' from the command line is $1 else error_fn "Your internal command didn't work " fi #now I will check the second arg echo "The contents of the second directory you entered are:" ls $2 #this checks to see if the "ls $2" exited correctly if [ $? -ne 0 ] then error_fn "could not read the second directory: $2" fi #