0
I'm prone to calling date -s
instead of date -d
, and this can go badly when I call it on the wrong server. Is there a way to add a confirmation prompt to date -s
so I realize what I've done?
0
I'm prone to calling date -s
instead of date -d
, and this can go badly when I call it on the wrong server. Is there a way to add a confirmation prompt to date -s
so I realize what I've done?
0
I can't help but state the obvious, that you should be more careful when typing commands... Nevertheless, I would suggest the following as a workaround.
Write a script , that checks the CLI arguments passed to the date
command, let's call it /bin/date.sh
(example below) and change its permission to 755
:
chmod 755 /bin/date.sh
cat /bin/date.sh
#!/bin/bash
### script to prompt at 'date -s'
if [[ $1 == -s* ]]; then
read -p "*** Are you sure you want to set the date ? [y/n]" ANS
if [[ $ANS = [Yy] ]]; then
/bin/date $1
fi
else
/bin/date $1
fi
Make an alias in your user's .bashrc
file to that script instead like alias date=/bin/date.sh
. This way, every time you call date
that script is run and it lets you know you issued the set date command flag and asks for confirmation.
You may also avoid using an alias, by simply replacing the date
command, like below, but please also change the date binary's name in the script from /bin/date
to /bin/date_cmd
mv /bin/date /bin/date_cmd mv /bin/date.sh /bin/date
Hope this helps!
Thank you! I'll see about getting this implemented. I would definitely prefer to check my commands before putting them through, but sometimes there's an intersection of 3 AM and Linux. – ub3rman123 – 2018-01-16T15:20:18.447