Arguments to a ksh script

Updated: April 19, 2023

Suppose we have a script called ksh_script that looks like this:

#! /bin/sh
echo $0
for arg in "$@" ; do
  echo $arg
done

If you invoke it as ./ksh_script one two three, the loader invokes it as /bin/sh ./ksh_script one two three, and then ksh removes itself from the argument list. The output looks like this:

./ksh_script
one
two
three