#!/bin/bash # ========== # $File: //scripts/triggers/noTypeChange.sh $ # $Revision: #2 $ # $Change: 112994 $ # # $Author: amorriss $ # $DateTimeTZ: 2019/02/14 10:41:57 +0000 GMT $ # ---------- # PURPOSE: # Bash script called from pre-command trigger, firing when 'p4 add/edit/reopen' is run. # This checks the arguments passed to the command ('argsQuoted' trigger script variable), checking for the flag that allows a type change ('-t'). # If found, the command is rejected with a sensible warning message. # # Example trigger entry: # notypechange command pre-user-(add|edit|reopen) "%//scripts/triggers/noTypeChange.sh% %user% %client% %serverid% %command% %argsQuoted%" # # ---------- # Next steps: # - enhance the trigger - more control/error-handling/logging? # - find a use for (or simply remove) 'user', 'client', 'server'; at present, only command and argsQuoted are used. user=$1 client=$2 server=$3 cmd=$4 argsQuoted=$5 echo $argsQuoted | grep -e "-t" > /dev/null; out=$? if [ $out = 0 ]; then echo Use of '-t' flag with $cmd is disallowed. exit 1; fi exit 0
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 26331 | Adam Morriss | keyword and executable | ||
#2 | 26330 | Adam Morriss | Switching to executable file | ||
#1 | 25125 | Adam Morriss |
Small command-trigger script to block '-t' on add/edit/reopen. Includes suggested trigger definition, and a header to explain the purpose. |