This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
help="usage: source scl_source <action> [<collection> ...] | |
Enable one or more collections in the current shell. | |
Options: | |
-h, --help display this help and exit" | |
if [ $1 = "-h" -o $1 = "--help" ]; then | |
echo "$help" | |
return 0 | |
fi | |
scriptlet_name=$1 | |
shift 1 | |
scls=() | |
prefixes=() | |
for scl in "$@"; do | |
prefix_file=/etc/scl/prefixes/${scl} | |
prefix=`cat $prefix_file 2>/dev/null` | |
if [ $? -ne 0 ]; then | |
echo "Can't read $prefix_file, $scl is probably not installed." | |
return 1 | |
fi | |
enabled=`scl_enabled $scl` | |
if [ $? -ne 0 ]; then | |
scls+=($scl) | |
prefixes+=($prefix) | |
fi; | |
done | |
for i in ${!prefixes[@]}; do | |
scriptlet_path="${prefixes[$i]}/${scls[$i]}/${scriptlet_name}" | |
source "$scriptlet_path" | |
if [ $? -ne 0 ]; then | |
echo "Can't source $scriptlet_name, skipping." | |
else | |
export X_SCLS="${scls[$i]} $X_SCLS" | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment