csh alias with variable number of arguments

后端 未结 3 425
孤街浪徒
孤街浪徒 2021-01-28 13:58

I would like to create a csh alias that performs one operation if invoked without arguments and a second operation if invoked with a single argument. Does anyone know how to do

3条回答
  •  盖世英雄少女心
    2021-01-28 14:42

    I know this is a bit late but I just ran into needing something similar and hope it might still be relevant to somebody.

    You can set the arguments as an array and query based on the size of the array:

    alias testing 'set args_=(\!*); if ($#args_ > 0)  echo "this command has $#args_ arguments" endif'
    

提交回复
热议问题