1

I am trying to use curl qrenco.de/google.com with an alias so that the alias takes the input parameter google.com and appends it to curl qrenco.de/. i want it to look something like this:
$qrcode google.com

i have tried the following:
alias qrcode='curl qrenco.de/$(read)'

but this doesn't seem to work. i am new to bash and would like to know the right approach.

2

1 Answer 1

1

Almost every time an alias gives you trouble, you should just be using a function.

qrcode() { curl qrenco.de/"$1"; }
Sign up to request clarification or add additional context in comments.

3 Comments

thank you. i have found a work around using a similar command alias qrcode='f(){ curl qrenco.de/"$@"; unset -f f; }; f' but could not understand this. can you help me with this?
what does unset -f f; mean?
unset removes something like a variable from the env. -f says the thing is a function. In this example, the name of the function is f. What that does is uses an alias to create a function every time that un-creates itself when it runs - then call the function. Seems silly to me. Just drop the alias and make a function instead. Why use both to create exactly the same function over and over?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.