+# Install a tinyos.sh invocation in user shell rc files.
+installshrc()
+{
+ for rc in $RCFILES; do
+ if [ -f $rc ] && ! grep -q "$TOSBASE/tinyos.sh" $rc; then
+ echo "[ -d $TOSBASE ] && . $TOSBASE/tinyos.sh" >> $rc 2>/dev/null
+ fi
+ done
+}
+
+# Uninstall the tinyos.sh invocation in user shell rc files.
+uninstallshrc()
+{
+ for rc in $RCFILES; do
+ if [ -f $rc ] && grep -q "$TOSBASE/tinyos.sh" $rc; then
+ grep -v "$TOSBASE/tinyos.sh" $rc > $rc.$$
+ mv -f $rc.$$ $rc
+ fi
+ done
+}
+
+# List available TinyOS source versions
+listsources()
+{
+ echo -n "Available sources:"
+ find $TOSBASE -maxdepth 2 -name tos -type d 2>/dev/null | sort | \
+ while read dir; do
+ echo -n " $(basename -- $(dirname -- $dir))"
+ done
+ echo
+}
+
+# MAIN
+
+if [ "$1" = "-t" ]; then
+ # Display TOS environment
+ if [ -z "$TOSROOT" ]; then
+ echo "tinyos: NOT configured"
+ else
+ echo "TOSROOT=$TOSROOT"
+ fi
+elif [ "$1" = "-l" ]; then
+ listsources
+elif [ "$1" = "-h" ]; then
+ cat <<EOF1
+Each TinyOS user must type the following to configure their login:
+
+ . $TOSBASE/tinyos.sh <version>
+
+<version> is the version of an installed source tree or the filesystem path to
+a TinyOS source tree