Skip to content

Cross OS fish shell function for package management #9163

Closed Answered by MANICX100
MANICX100 asked this question in Q&A
Discussion options

You must be logged in to vote

@faho - thank you for the answer and further assistance.

Any idea why my switch statements always evaluate to fail

alias getos="grep -ioP '^ID=\K.+' /etc/os-release"
set osinfo getos

This... creates a variable "osinfo" and sets it to the string "getos". It doesn't run the function.

You want:

alias getos="grep -ioP '^ID=\K.+' /etc/os-release"
set -g osinfo (getos)

or, tbh

set -g osinfo (grep -ioP '^ID=\K.+' /etc/os-release)

The -g makes it specifically create a global variable. If you didn't pass that, it could use a pre-existing variable instead.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@faho
Comment options

@MANICX100
Comment options

@MANICX100
Comment options

@faho
Comment options

@MANICX100
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by MANICX100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants