Make more function variables local to avoid polluting the environment
[config/bash.git] / .bash / aliases.d / record
index 00372b3..fb90aa7 100644 (file)
@@ -4,16 +4,19 @@ if command -v script &> /dev/null;
 then
   function record()
   {
+    local TIMESTAMP
     TIMESTAMP="$(date '+%Y-%m-%d-%H:%M:%S')"
 
     # The trick here is to use 'type' to eat any leading environment variables
     # and get to the command name.
+    local COMMAND_NAME
     COMMAND_NAME="$(type -P "$@" 2>/dev/null | cut -d ' ' -f 1)"
 
     [ "x$COMMAND_NAME" = "x" ] && return 1
 
     # Escape the argument so that it can be reused as shell input
     # NOTE: this is Bash specific.
+    local COMMAND_ESCAPED
     COMMAND_ESCAPED=$(printf "%q " "$@")
 
     script -q -e -c "$COMMAND_ESCAPED" "${TIMESTAMP}_$(basename "$COMMAND_NAME").log"