[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling a function with a shorter name
From: |
Eli Schwartz |
Subject: |
Re: Calling a function with a shorter name |
Date: |
Tue, 13 Apr 2021 22:07:01 -0400 |
On 4/13/21 9:52 PM, michael-franzese@gmx.com wrote:
>
> Have written a function with a long name. I want to use it with a very
short
> name somewhere else to improve readability. Have looked into the command
> alias,
> but I get "command not found" when I call the shorter version.
Did you actually look at which command is not being found? Did you *tell
us* which command is not being found? This is important information,
albeit information which some people know to expect.
Why are you using aliases in scripts anyway?
> ----- tools.sh -----
> chtcolr () { ... }
> alias ct='chtcolr'
> ----- tools.sh -----
>
> ----- test.sh -----
> source ./tools.sh
> ct $a $b
> ----- test.sh -----
The actual reproducing case you showed here does not require creating a
chtcolr function, just name it "ct" when you create it.
Or, since it is a script and length is irrelevant and saving 5 bytes in
your script isn't a huge efficiency saver, just use the full name.
...
Or, read the bash manpage, section "ALIASES", take note of paragraph 4.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
OpenPGP_signature
Description: OpenPGP digital signature