help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mimick namespace in bash?


From: Eli Schwartz
Subject: Re: mimick namespace in bash?
Date: Sun, 3 May 2020 22:16:35 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/3/20 9:53 PM, Peng Yu wrote:
> Hi,
> 
> It seems that hash and alias does not support "/" in the command. Is it so?
> 
> If it does, it can be used to mimick namespace. Should this feature be
> considered to be added to bash?
> 
> $ builtin hash -p /usr/local/opt/coreutils/libexec/gnubin/ls my/ls
> $ my/ls
> -bash: my/ls: No such file or directory
> 
> $ alias my/ls=/usr/local/opt/coreutils/libexec/gnubin/ls
> -bash: alias: `my/ls': invalid alias name

There are already plenty of things you can use for namespacing, why do
you need something that looks like a directory name?

Following a pattern used in some real programming languages:

$ alias my::ls='echo "namespaced ls"'
$ my::ls
namespaced ls

And since aliases are inferior things:

$ my::ls2() { echo "another namespaced ls"; }
$ my::ls2
another namespaced ls
$ my/ls() { echo "why do you do this"; }
$ my/ls
why do you do this

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]