Search code examples
tcsh

tcsh: How to clear command line arguments after use?


I have a script called release.csh that takes in command line arguments. This script calls 'source sourceme' where sourceme is another script of which I have no control over. The command line arguments passed to 'release.csh' end up getting used by 'sourceme' even though I don't explicitly pass command line arguments to 'sourceme'. So how can I clear command line arguments inside release.csh so that it doesn't mess up 'sourceme'?

#!/usr/intel/bin/tcsh

# The release.csh script takes in the release version as a cmd line arg
set releaseVer = $1

# But when I call the 'sourceme' script, the cmd line args get passed
# So I want to clear the cmd line args here
source ConfigFiles/sourceme

Solution

  • tcsh's command-line arguments are in the variable $argv (also visible as $1, $2, etc.).

    To clear them:

    set argv = ()
    

    (obligatory link)