2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-15 06:12:59 +00:00

Merge pull request #138 from terminalforlife/master

Improve `lenchk` and Fix Some Line Lengths
This commit is contained in:
Igor Chubin 2020-11-18 16:59:02 +01:00 committed by GitHub
commit c4ca01581d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 17 deletions

View File

@ -1,13 +1,17 @@
# dpkg-deb
# Debian package archive (.deb) manipulation tool
# Build a DEB package using the provided directory.
dpkg-deb -b /path/to/directory
# List out the contents of an existing DEB package.
dpkg-deb -c /path/to/package.deb
# Extract the contents of an existing DEB package. If no destination is provided
# for the extracted files, then they will be extracted to the CWD. Will also create
# the specified directory if it's not found, but it won't create its parents.
# Extract the contents of an existing DEB package. If no destination is
# provided for the extracted files, then they will be extracted to the CWD.
# Will also create the specified directory if it's not found, but it won't
# create its parents.
dpkg-deb -x /path/to/package.deb /path/to/destination/
# Output a (unique) list of available sections under which to create a DEB package.
# Output (unique) list of available sections under which to create DEB package.
awk '!A[$1]++{print($1)}' <<< "$(dpkg-query --show -f='${Section}\n')"

View File

@ -1,11 +1,12 @@
# system_profiler
# Report system hardware and software configuration (Mac OS X)
# Display a full system profiler report which can be opened by System Profiler.app:
# Display a full system profiler report which can be opened by
# 'System Profiler.app'.
system_profiler -xml > MyReport.spx
# Display a hardware overview (Model, CPU, Memory, Serial, etc):
# Display an overview of system hardware (Model, CPU, Memory, Serial, etc).
system_profiler SPHardwareDataType
# Print the system serial number:
# Print the system's serial number.
system_profiler SPHardwareDataType|grep "Serial Number (system)" |awk '{print $4}'

View File

@ -148,20 +148,31 @@ Main(){
for File in "${Dirs[@]}"; {
[ -f "$File" ] || continue
# Per chubin's desire to have an "in-bound flag"; see #134.
if [ "$NoLenChkLine" != 'True' ]; then
SkipFile='False'
readarray -t Buffer < "$File"
for BufferLine in "${Buffer[@]}"; {
if [[ $BufferLine == '# cheat.sh: '* ]]; then
CheatLine=${BufferLine#'# cheat.sh: '}
IFS=',' read -a Fields <<< "$CheatLine"
for Field in "${Fields[@]}"; {
[ "$Field" == "$Progrm=disable" ] && SkipFile='True'
}
fi
}
[ "$SkipFile" == 'True' ] && continue
fi
# If the current file matches one which is whitelisted, skip it.
for CurWL in "${Whitelisted[@]}"; {
[ "$File" == "$CurWL" ] && continue 2
}
# Per chubin's desire to have an "in-bound flag"; see #134 for info.
if [ "$NoLenChkLine" != 'True' ]; then
read Buffer < "$File"
[ "$Buffer" == 'lenchk=disable' ] && continue
fi
HaveBeenHit='False'
LineNum=0
HaveBeenHit='False'
while read; do
let LineNum++
@ -218,16 +229,20 @@ Main(){
if [ -t 1 -a "$NoPager" != 'True' ]; then
# Prefer less(1), but have more(1) as a fallback.
if type -fP less &> /dev/null; then
Pager='less'
Pager='less -R'
elif type -fP more &> /dev/null; then
Pager='more'
if [ "$NoColor" != 'True' ]; then
Err 1 'Only more(1) is available -- colors unsupported.'
fi
else
Err 1 'Neither less(1) nor more(1) were found.'
fi
# Redirecting STDERR to address less(1) bug causing summary to display
# where it shouldn't; only seems to happen when colorization is enabled.
Main 2>&1 | $Pager -r
Main 2>&1 | $Pager
else
Main