aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-08-13 23:50:48 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2016-08-13 23:50:48 +0200
commit8fec942ab9913a38423a4cfea37d29ea304ddd0e (patch)
tree5a7ea2c281ee34840ce6d4db5232707ff004f464
parentfix ShellCheck warnings (diff)
downloadlinux-home-8fec942ab9913a38423a4cfea37d29ea304ddd0e.tar.gz
linux-home-8fec942ab9913a38423a4cfea37d29ea304ddd0e.zip
code style
Diffstat (limited to '')
-rw-r--r--.bashrc_cxx208
-rw-r--r--.bashrc_distr20
-rw-r--r--.bashrc_git160
-rw-r--r--.bashrc_netwrix24
-rw-r--r--.bashrc_text8
-rw-r--r--.bashrc_third_party46
6 files changed, 233 insertions, 233 deletions
diff --git a/.bashrc_cxx b/.bashrc_cxx
index 83aa24b..848e190 100644
--- a/.bashrc_cxx
+++ b/.bashrc_cxx
@@ -1,119 +1,119 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_CXX+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_CXX=1
+ readonly BASHRC_CXX=1
fi
C_FLAGS=('-Wall' '-Wextra')
runc() (
- set -o errexit
-
- local -a c_flags=("${C_FLAGS[@]}")
- local -a src_files=()
- local -a prog_flags=()
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- -c|--c-flags)
- if [ "$#" -le 1 ]; then
- echo "${FUNCNAME[0]}: missing argument for parameter: $1" >&2
- return 1
- fi
- shift
- c_flags+=("$1")
- shift
- ;;
-
- -h)
- echo "usage: ${FUNCNAME[0]} [-h] [-c|--c-flags FLAG]"
- return 0
- ;;
-
- --)
- shift
- break
- ;;
-
- *)
- src_files+=("$( realpath "$1" )")
- shift
- ;;
- esac
- done
-
- prog_flags=("$@")
-
- local build_dir
- build_dir="$( mktemp --directory )"
-
- trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
- pushd "$build_dir" > /dev/null
-
- local output_name
- output_name="$( mktemp --tmpdir=. "${FUNCNAME[0]}XXX.exe" )"
-
- gcc -o "$output_name" \
- "${c_flags[@]+"${c_flags[@]}"}" \
- "${src_files[@]+"${src_files[@]}"}"
-
- "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
+ set -o errexit
+
+ local -a c_flags=("${C_FLAGS[@]}")
+ local -a src_files=()
+ local -a prog_flags=()
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -c|--c-flags)
+ if [ "$#" -le 1 ]; then
+ echo "${FUNCNAME[0]}: missing argument for parameter: $1" >&2
+ return 1
+ fi
+ shift
+ c_flags+=("$1")
+ shift
+ ;;
+
+ -h)
+ echo "usage: ${FUNCNAME[0]} [-h] [-c|--c-flags FLAG]"
+ return 0
+ ;;
+
+ --)
+ shift
+ break
+ ;;
+
+ *)
+ src_files+=("$( realpath "$1" )")
+ shift
+ ;;
+ esac
+ done
+
+ prog_flags=("$@")
+
+ local build_dir
+ build_dir="$( mktemp --directory )"
+
+ trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
+ pushd "$build_dir" > /dev/null
+
+ local output_name
+ output_name="$( mktemp --tmpdir=. "${FUNCNAME[0]}XXX.exe" )"
+
+ gcc -o "$output_name" \
+ "${c_flags[@]+"${c_flags[@]}"}" \
+ "${src_files[@]+"${src_files[@]}"}"
+
+ "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
)
CXX_FLAGS=('-Wall' '-Wextra' '-std=c++14')
runcxx() (
- set -o errexit
-
- local cxx_flags=("${CXX_FLAGS[@]}")
- local -a src_files=()
- local -a prog_flags=()
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- -c|--cxx-flags)
- if [ "$#" -le 1 ]; then
- echo "${FUNCNAME[0]}: missing argument for parameter: $1" >&2
- return 1
- fi
- shift
- cxx_flags+=("$1")
- shift
- ;;
-
- -h)
- echo "usage: ${FUNCNAME[0]} [-h] [-c|--cxx-flags FLAG]"
- return 0
- ;;
-
- --)
- shift
- break
- ;;
-
- *)
- src_files+=("$( realpath "$1" )")
- shift
- ;;
- esac
- done
-
- prog_flags=("$@")
-
- local build_dir
- build_dir="$( mktemp --directory )"
-
- trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
- pushd "$build_dir" > /dev/null
-
- local output_name
- output_name="$( mktemp --tmpdir=. "${FUNCNAME[0]}XXX.exe" )"
-
- g++ -o "$output_name" \
- "${cxx_flags[@]+"${cxx_flags[@]}"}" \
- "${src_files[@]+"${src_files[@]}"}"
-
- "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
+ set -o errexit
+
+ local cxx_flags=("${CXX_FLAGS[@]}")
+ local -a src_files=()
+ local -a prog_flags=()
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -c|--cxx-flags)
+ if [ "$#" -le 1 ]; then
+ echo "${FUNCNAME[0]}: missing argument for parameter: $1" >&2
+ return 1
+ fi
+ shift
+ cxx_flags+=("$1")
+ shift
+ ;;
+
+ -h|--help)
+ echo "usage: ${FUNCNAME[0]} [-h|--help] [-c|--cxx-flags FLAG]"
+ return 0
+ ;;
+
+ --)
+ shift
+ break
+ ;;
+
+ *)
+ src_files+=("$( realpath "$1" )")
+ shift
+ ;;
+ esac
+ done
+
+ prog_flags=("$@")
+
+ local build_dir
+ build_dir="$( mktemp --directory )"
+
+ trap "$( printf 'popd > /dev/null && rm -rf %q' "$build_dir" )" 0
+ pushd "$build_dir" > /dev/null
+
+ local output_name
+ output_name="$( mktemp --tmpdir=. "${FUNCNAME[0]}XXX.exe" )"
+
+ g++ -o "$output_name" \
+ "${cxx_flags[@]+"${cxx_flags[@]}"}" \
+ "${src_files[@]+"${src_files[@]}"}"
+
+ "$output_name" "${prog_flags[@]+"${prog_flags[@]}"}"
)
diff --git a/.bashrc_distr b/.bashrc_distr
index 6534378..8968ca5 100644
--- a/.bashrc_distr
+++ b/.bashrc_distr
@@ -1,26 +1,26 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_DISTR+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_DISTR=1
+ readonly BASHRC_DISTR=1
fi
checksums_path='sha1sums.txt'
update_checksums() {
- sha1sum -- "$@" > "$checksums_path"
+ sha1sum -- "$@" > "$checksums_path"
}
update_checksums_distr() {
- local -a paths=()
- local path
- while IFS= read -r -d $'\0' path; do
- paths+=("$path")
- done < <( find . -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -print0 )
- update_checksums "${paths[@]+"${paths[@]}"}"
+ local -a paths=()
+ local path
+ while IFS= read -r -d $'\0' path; do
+ paths+=("$path")
+ done < <( find . -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -print0 )
+ update_checksums "${paths[@]+"${paths[@]}"}"
}
verify_checksums() {
- sha1sum --check "$checksums_path"
+ sha1sum --check "$checksums_path"
}
diff --git a/.bashrc_git b/.bashrc_git
index ba7e6a8..751f417 100644
--- a/.bashrc_git
+++ b/.bashrc_git
@@ -1,101 +1,101 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_GIT+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_GIT=1
+ readonly BASHRC_GIT=1
fi
list_repo_files() (
- local -a cmd=(git ls-files)
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- -z|-0)
- cmd+=(-z)
- shift
- ;;
-
- -h)
- echo "usage: ${FUNCNAME[0]} [-h] [-z|-0]"
- return 0
- ;;
-
- *)
- echo "${FUNCNAME[0]}: unrecognized parameter: $1" >&2
- return 1
- ;;
- esac
- done
-
- eval "${cmd[@]}"
+ local -a cmd=(git ls-files)
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -z|-0)
+ cmd+=(-z)
+ shift
+ ;;
+
+ -h|--help)
+ echo "usage: ${FUNCNAME[0]} [-h|--help] [-z|-0]"
+ return 0
+ ;;
+
+ *)
+ echo "${FUNCNAME[0]}: unrecognized parameter: $1" >&2
+ return 1
+ ;;
+ esac
+ done
+
+ eval "${cmd[@]}"
)
list_repo_dirs() (
- set -o errexit
-
- local terminator='\n'
-
- while [ "$#" -gt 0 ]; do
- case "$1" in
- -z|-0)
- terminator='\000'
- shift
- ;;
-
- -h)
- echo "usage: ${FUNCNAME[0]} [-h] [-z|-0]"
- return 0
- ;;
-
- *)
- echo "${FUNCNAME[0]}: unrecognized parameter: $1" >&2
- return 1
- ;;
- esac
- done
-
- { printf '.\0' ; list_repo_files -z ; } \
- | xargs -0 dirname -z \
- | sort -uz \
- | tail -z -n +2 \
- | tr '\000' "$terminator"
+ set -o errexit
+
+ local terminator='\n'
+
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -z|-0)
+ terminator='\000'
+ shift
+ ;;
+
+ -h|--help)
+ echo "usage: ${FUNCNAME[0]} [-h|--help] [-z|-0]"
+ return 0
+ ;;
+
+ *)
+ echo "${FUNCNAME[0]}: unrecognized parameter: $1" >&2
+ return 1
+ ;;
+ esac
+ done
+
+ { printf '.\0' ; list_repo_files -z ; } \
+ | xargs -0 dirname -z \
+ | sort -uz \
+ | tail -z -n +2 \
+ | tr '\000' "$terminator"
)
tighten_repo_security() (
- set -o errexit
+ set -o errexit
- list_repo_files -z | xargs -0 chmod 0600
- list_repo_dirs -z | xargs -0 chmod 0700
- chmod 0700 .git
+ list_repo_files -z | xargs -0 chmod 0600
+ list_repo_dirs -z | xargs -0 chmod 0700
+ chmod 0700 .git
)
backup_repo() (
- set -o errexit
-
- local repo_dir
- repo_dir="$( realpath . )"
- local repo_name
- repo_name="$( basename "$repo_dir" )"
- local backup_dir="$repo_dir"
-
- if [ $# -eq 1 ]; then
- backup_dir="$1"
- elif [ $# -gt 1 ]; then
- echo "usage: ${FUNCNAME[0]} [BACKUP_DIR]" >&2
- exit 1
- fi
-
- local zip_name
- zip_name="${repo_name}_$( date -u +'%Y%m%dT%H%M%S' ).zip"
-
- git archive \
- --format=zip -9 \
- --output="$backup_dir/$zip_name" \
- --remote="$repo_dir" \
- HEAD
+ set -o errexit
+
+ local repo_dir
+ repo_dir="$( realpath . )"
+ local repo_name
+ repo_name="$( basename "$repo_dir" )"
+ local backup_dir="$repo_dir"
+
+ if [ $# -eq 1 ]; then
+ backup_dir="$1"
+ elif [ $# -gt 1 ]; then
+ echo "usage: ${FUNCNAME[0]} [BACKUP_DIR]" >&2
+ exit 1
+ fi
+
+ local zip_name
+ zip_name="${repo_name}_$( date -u +'%Y%m%dT%H%M%S' ).zip"
+
+ git archive \
+ --format=zip -9 \
+ --output="$backup_dir/$zip_name" \
+ --remote="$repo_dir" \
+ HEAD
)
backup_repo_dropbox() {
- backup_repo "$USERPROFILE/Dropbox/backups"
+ backup_repo "$USERPROFILE/Dropbox/backups"
}
diff --git a/.bashrc_netwrix b/.bashrc_netwrix
index 5b6211a..6372a89 100644
--- a/.bashrc_netwrix
+++ b/.bashrc_netwrix
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_NETWRIX+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_NETWRIX=1
+ readonly BASHRC_NETWRIX=1
fi
source .bashrc_git || return
@@ -14,20 +14,20 @@ export nwx_dev2=172.28.19.60
export nwx_dev3=172.28.19.61
lint_webapi() (
- set -o errexit
+ set -o errexit
- local root_dir='/cygdrive/c/Netwrix Auditor/CurrentVersion-AuditCore-Dev/AuditCore/Sources'
+ local root_dir='/cygdrive/c/Netwrix Auditor/CurrentVersion-AuditCore-Dev/AuditCore/Sources'
- cd "$root_dir/Configuration"
- doslint WebAPI*.acinc WebAPI*.acconf
+ cd "$root_dir/Configuration"
+ doslint WebAPI*.acinc WebAPI*.acconf
- cd "$root_dir/Subsystems/PublicAPI"
- local path
- find . -type f -\( -iname '*.cpp' -o -iname '*.h' -\) | while read -r path ; do
- doslint "$path"
- done
+ cd "$root_dir/Subsystems/PublicAPI"
+ local path
+ find . -type f -\( -iname '*.cpp' -o -iname '*.h' -\) | while read -r path; do
+ doslint "$path"
+ done
)
backup_repo_nwx() {
- backup_repo '//spbfs02/P/Personal/Egor Tensin'
+ backup_repo '//spbfs02/P/Personal/Egor Tensin'
}
diff --git a/.bashrc_text b/.bashrc_text
index 2b32195..1641859 100644
--- a/.bashrc_text
+++ b/.bashrc_text
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_TEXT+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_TEXT=1
+ readonly BASHRC_TEXT=1
fi
alias dos2eol='sed --binary --in-place '"'"'s/\(\r\?\)$//'"'"
@@ -20,9 +20,9 @@ alias doseol='sed --binary --in-place '"'"'$s/\r\?$/\r/;a\'"'"
alias trimbom='sed --binary --in-place '"'"'1 s/^\xef\xbb\xbf//'"'"
lint() {
- trim "$@" && trimeol "$@" && eol "$@"
+ trim "$@" && trimeol "$@" && eol "$@"
}
doslint() {
- trim "$@" && trimdoseol "$@" && doseol "$@"
+ trim "$@" && trimdoseol "$@" && doseol "$@"
}
diff --git a/.bashrc_third_party b/.bashrc_third_party
index 6d1e28c..48ea0b9 100644
--- a/.bashrc_third_party
+++ b/.bashrc_third_party
@@ -1,45 +1,45 @@
#!/usr/bin/env bash
if [ -n "${BASHRC_THIRD_PARTY+x}" ]; then
- return 0
+ return 0
else
- readonly BASHRC_THIRD_PARTY=1
+ readonly BASHRC_THIRD_PARTY=1
fi
ensure_symlinks_enabled() {
- case "${CYGWIN:-}" in
- *winsymlinks:native*) ;;
- *winsymlinks:nativestrict*) ;;
-
- *)
- echo "${FUNCNAME[0]}: native Windows symlinks aren't enabled in Cygwin" >&2
- return 1
- ;;
- esac
+ case "${CYGWIN:-}" in
+ *winsymlinks:native*) ;;
+ *winsymlinks:nativestrict*) ;;
+
+ *)
+ echo "${FUNCNAME[0]}: native Windows symlinks aren't enabled in Cygwin" >&2
+ return 1
+ ;;
+ esac
}
symlink_preferences() (
- set -o errexit
+ set -o errexit
- ensure_symlinks_enabled
+ ensure_symlinks_enabled
- if [ "$#" -ne 2 ]; then
- echo "usage: ${FUNCNAME[0]} SRC_DIR DEST_DIR" >&2
- return 1
- fi
+ if [ "$#" -ne 2 ]; then
+ echo "usage: ${FUNCNAME[0]} SRC_DIR DEST_DIR" >&2
+ return 1
+ fi
- local src_dir="$1"
- local dest_dir="$2"
+ local src_dir="$1"
+ local dest_dir="$2"
- [ -d "$dest_dir" ] || mkdir -p "$dest_dir"
+ mkdir -p "$dest_dir"
- find "$src_dir" -maxdepth 1 -type f -exec ln --force -s {} "$dest_dir" \;
+ find "$src_dir" -maxdepth 1 -type f -exec ln --force -s {} "$dest_dir" \;
)
symlink_sublime_preferences() {
- symlink_preferences "$HOME/.Sublime Text 3" "$APPDATA/Sublime Text 3/Packages/User"
+ symlink_preferences "$HOME/.Sublime Text 3" "$APPDATA/Sublime Text 3/Packages/User"
}
symlink_ghc_preferences() {
- symlink_preferences "$HOME/.GHC" "$APPDATA/ghc"
+ symlink_preferences "$HOME/.GHC" "$APPDATA/ghc"
}