I want to store options to arbitrary commands as strings in bash so that I can do e.g.
presets_A='-A'
presets_B='-A -l -F'
ls $presets_A
ls $presets_B
The first one works, the socond gives ls: invalid option -- ' '.
The same happens when I try to store the entire command in a string variable (as opposed to a function or an alias, which is not what I want):
presets_A='ls -A'
presets_B='ls -A -l -F'
$presets_A
$presets_B
This gives ls -A: command not found. Not good. Obviously, I haven't yet found the correct arbitrary
mixture of $%"(@]}" quotes and parens that Bash is so famous for. ${!presets_A} also didn't work
but chances are I got confused and messed up.
EDIT for clarification, I do know how to use a function to encapsulate setting options and subsuming a bunch of parametrized calls under a single command. What I'm looking for is the equivalent of (Bash) foo "$@" or (Python) foo( *P, **Q ) or JS foo( ...P ) such that I get a single serializable and transportable value that comprises the arguments to a call in a single place.
IFS?presets_B='-A -l -F'followed byls $presets_B- could you expand on your question so that we can reproduce your issue?alias lB="ls -A -l -F"