参数数目可变的csh别名 [英] csh alias with variable number of arguments

查看:101
本文介绍了参数数目可变的csh别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个csh别名,如果不带参数调用,则执行一个操作,如果带单个参数调用,则执行第二个操作.有谁知道如何做到这一点? (尝试引用未传递的参数会触发错误).

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 this? (Attempting to refer to an argument that wasn't passed triggers an error).

推荐答案

我知道这有点晚了,但是我遇到了类似的问题,希望它可能仍然与某人有关.

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'

这篇关于参数数目可变的csh别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆