#!/bin/csh -f # make_links_up_the_tree # ------------------------------------------------------------------------- # Shell script to create symlinks in the current directory that point to # the same name in the parent directory, recursively on up the tree, until # such a file or symlink is found to exist. Also, optionally publish # such links to the remote server. # ------------------------------------------------------------------------- # Revision History: # $Log$ # ------------------------------------------------------------------------- # Collect command line options set option_local = "false" while ($#argv > 0) if ("$1" == "-h" || "$1" == "--help") then echo "Usage: $0:t [options] symlink_name" echo "Options:" echo " -h = Show this help text" echo " --help = Show this help text" echo " -l = Local -- Don't publish updated files" exit 1 else if ("$1" == "-l") then shift set option_local = "true" else if ("-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0 --help exit 1 else # Not a recognized option. Assume it's the first argument break endif end # Collect command line arguments if ($#argv > 1) then echo "Error: Too many arguments" $0 --help exit 1 else if ($#argv < 1) then echo "Error: symlink_name is required" $0 --help exit 1 endif # Loop until the specified file exists, or a symlink exists and resolves # to an existing file. while (! -e $1:q) # Either the symlink does not exist, or its target does not. # Check to see if the symlink exists if (! -l $1:q) then # Create the symlink, echoing it to the user. The explicit $cwd # is to make the line echoed by -v more self-explanatory. make_symlink_if_necessary $cwd/$1:q ../$1:q if ($status) then beep "Error creating symlink $cwd/$1" exit 2 endif if ("$option_local" == "false") then remotepub -auto $1:q if ($status) then beep "Error publishing symlink $cwd/$1" exit 2 endif endif endif cd .. if ($status) then beep "Error moving to directory $cwd/.." exit 3 endif end