* Make a function name an alias for another function
@ 2021-09-04 16:42 Eric Smith
0 siblings, 0 replies; 3+ messages in thread
From: Eric Smith @ 2021-09-04 16:42 UTC (permalink / raw)
To: zsh-users
Hey zsh-ers,
I would like to have a function defined in one place.
POST() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
GET() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
DELETE() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
Not three like this.
How can I make like
POST() = GET()
Then I can call GET() and it will run the same function but return of cause an alternate $0
Thanks for any tips.
Best wishes
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make a function name an alias for another function
2021-09-04 16:21 Eric Smith
@ 2021-09-04 16:24 ` Roman Perepelitsa
0 siblings, 0 replies; 3+ messages in thread
From: Roman Perepelitsa @ 2021-09-04 16:24 UTC (permalink / raw)
To: Eric Smith; +Cc: Zsh Users
On Sat, Sep 4, 2021 at 6:22 PM Eric Smith <es@fruitcom.com> wrote:
>
> How can I make like
> POST() = GET()
> Then I can call GET() and it will run the same function but return of cause an alternate $0
Like this:
POST GET DELETE() { cur --silent -X "$0" ... }
Roman.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Make a function name an alias for another function
@ 2021-09-04 16:21 Eric Smith
2021-09-04 16:24 ` Roman Perepelitsa
0 siblings, 1 reply; 3+ messages in thread
From: Eric Smith @ 2021-09-04 16:21 UTC (permalink / raw)
To: zsh-users
Hey zsh-ers,
I would like to have a function defined in one place.
POST() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
GET() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
DELETE() {curl --silent -X $0 -H "Content-Type: application/json" http://admin:3/api/$@ | jq '.'}
Not three like this.
How can I make like
POST() = GET()
Then I can call GET() and it will run the same function but return of cause an alternate $0
Thanks for any tips.
Best wishes
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-04 16:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 16:42 Make a function name an alias for another function Eric Smith
-- strict thread matches above, loose matches on Subject: below --
2021-09-04 16:21 Eric Smith
2021-09-04 16:24 ` Roman Perepelitsa
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).