Reputation: 10920
raco pkg install <package-name>
installs a package if it does not yet exist, and fails if the package already exists. raco pkg update <package-name>
updates a package, and fails if the package does not yet exist.
Is there a raco command that combines both commands? In other words, is there a command that can install a package if it does not exist, and also update the package if it already exists?
Rationale: This kind of command would be useful in shell scripting. For example, in Debian/Ubuntu, the apt-get install
command has the exact required behaviour, and for python, pip install --upgrade
has that too. Is there an equivalent for raco?
Racket version: 6.11
Upvotes: 1
Views: 613
Reputation: 1113
You can use raco pkg show <package>
to detect if a package is installed, for example with something like:
mypkg='memoize'
if [ " [none]" = "$(raco pkg show '$mypkg' | tail -1)" ]; then
raco pkg install "$mypkg"
else
raco pkg update "$mypkg"
fi
Upvotes: 0