8

I'm using Fedora 25, and have added the following alias to my bash profile:

alias releasenotes="dnf updateinfo --refresh info `dnf check-update | cut -d '.' -f 1 | xargs` | less"

(I can't use straight-up dnf updateinfo info because of https://bugzilla.redhat.com/show_bug.cgi?id=1405191)

My alias works, but the command takes about 10 seconds to run, and since bash parses and validates all aliases when the profile is sourced, creating a new shell results in a 10-second hang. This is annoying.

Is there any way to make bash not try to parse and validate aliases--or just that one?

9

My best guess is you should probably use single quotes around the alias definition.

I know that when using double quotes, shell variables are replaced with their content at the alias definition stage (like you said parsing and validating) and backticks or shell substitution like $(command).

A better explanation is in this Unix SE question!

If that doesn't help making the prompt load faster again, define a shell function instead of an alias.

edit: Don't forget to swap the cut argument to double-quotes like quixotic mentioned.

| improve this answer | |
  • That did it! You answered first, so you get the credit. – iLikeDirt Mar 5 '17 at 14:52
9

bash is interpreting your quoted string, and that interpretation executes the embedded dnf check-update command. This execution is what takes up the time during the alias definition, not the main dnf updateinfo command you're aliasing. Try a contrived example based on sleep and note how the alias itself takes 5 seconds:

alias sleep5="echo 'wake' ; `sleep 5` ; echo 'done'"

Use single-quotes to avoid the interpretation:

alias releasenotes='dnf updateinfo --refresh info `dnf check-update | cut -d "." -f 1 | xargs` | less'

Don't forget to swap the cut argument to double-quotes.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.