0
Follow
5
View

Bash $@ equivalent in nushell

d20130101 注册会员
2023-01-26 08:46

It sounds like you are looking for Rest parameters:

def main [...args: string] {
    $args| each { echo $in }
}

> main one two three
╭───┬───────╮
│ 0 │ one   │
│ 1 │ two   │
│ 2 │ three │
╰───┴───────╯

args can be named whatever you want. The only "magic" variable in that example is $in, which could be replaced with the non-magic form:

    $args| each { |item| echo $item }