Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F28985252
whom-diff
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
whom-diff
View Options
#!/bin/sh
# -------------------------------------------------------------
# whom-diff
#
# Computes the diff between two `whom` invoke.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Author: Sébastien Santoro aka Dereckson
# Created: 2015-12-30
# Licence: BSD-2-Clause
# -------------------------------------------------------------
# -------------------------------------------------------------
# Determines session identifier and directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$SESSION_ID
"
=
""
]
;
then
SESSION_ID
=
`
who am I
|
md5
|
cut -c1-8
`
fi
DIR
=
/var/tmp/whom/
$USER
/
$SESSION_ID
# -------------------------------------------------------------
# -s / --session
# Prints the session identifier
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$1
"
=
"--session"
]
||
[
"
$1
"
=
"-s"
]
;
then
echo
$SESSION_ID
exit
0
fi
# -------------------------------------------------------------
# Default mode
# Prints the diff between current `whom` and previous output
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
$#
-eq
0
]
;
then
# Creates working directory if needed
if
[
! -d
$DIR
]
;
then
mkdir -p
$DIR
touch
$DIR
/old
fi
# Let's diff
cd
$DIR
whom > current
diff old current
|
tail -n +2
mv current old
exit
0
fi
# -------------------------------------------------------------
# -c / --clean
# Cleans directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if
[
"
$1
"
=
"--clean"
]
||
[
"
$1
"
=
"-c"
]
;
then
rm -rf
$DIR
exit
$?
fi
# -------------------------------------------------------------
# Usage
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
&
2
echo
"Usage:
$0
[--setup|--clean|-s|-c]"
exit
1
File Metadata
Details
Attached
Mime Type
text/x-shellscript
Expires
Sun, May 17, 19:04 (23 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3704111
Default Alt Text
whom-diff (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment