On Sat, Sep 2, 2017 at 1:56 PM, Mark Volkmann <r.mark.volkm...@gmail.com>
wrote:

> If I enter:
>
> alias greet 'echo Hello, $USER'
>
> and then enter:
>
> functions greet
>
> it outputs:
>
> # Defined in - @ line 0
> function greet --description 'alias greet echo Hello, $USER'
>   echo Hello, $USER $argv;
> end
>
> Why does the generated function output $argv?
>

Most of the time people use `*alias*` to wrap another command with some
predefined options. And you normally want to allow the user to augment
those with additional arguments. For example I have this alias:

alias h 'builtin history search -R -20 --show-time="%a %m-%d %R  "'

If I type `*h git*` I want to search for commands containing the word `*git*`.
It would also be quite surprising to define an alias that silently ignored
any arguments it was invoked with. If you do want a function that should
never be run with any arguments you should do so explicitly:

function greet
    if set -q argv[1]
        echo greet: no arguments allowed >&2
        exit 1
    end
    echo Hello $USER
end

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to