zsh-users
 help / color / mirror / Atom feed
* 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

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ https://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git