Skip to content

Instantly share code, notes, and snippets.

@bkabrda
Created September 4, 2013 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkabrda/6435016 to your computer and use it in GitHub Desktop.
Save bkabrda/6435016 to your computer and use it in GitHub Desktop.
#!/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