SCREENDIR checks.
authorIain Patterson <me@iain.cx>
Wed, 10 Mar 2010 14:20:00 +0000 (14:20 +0000)
committerIain Patterson <me@iain.cx>
Thu, 18 Mar 2010 15:50:47 +0000 (15:50 +0000)
Use bash builtin -g to check for setgid screen.
Make SCREENDIR if it doesn't already exist.

.profile.d/screen.bashrc

index 440395e..beba505 100644 (file)
@@ -1,12 +1,13 @@
 # Fixup screen and define ``session'' if available.
 screen=$(find_working screen 2>/dev/null)
 if [ $? = 0 ]; then
-  # Override SCREENDIR iff screen is not setuid (but not under sudo).
-  if ! ls -l "$screen" | cut -d ' ' -f 1 | grep s >/dev/null; then
+  # Override SCREENDIR iff screen is not setgid (but not under sudo).
+  if [ ! -g "$screen" ]; then
     if [ -n "$SUDO_USER" ]; then
       unset SCREENDIR
     else
-      export SCREENDIR="${PROFILE_HOME:-~}/.screen/$HOSTNAME"
+      export SCREENDIR="~/.screen/$HOSTNAME"
+      mkdir -p "$SCREENDIR"
     fi
   fi