diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-08-13 23:50:48 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-08-13 23:50:48 +0200 |
commit | 8fec942ab9913a38423a4cfea37d29ea304ddd0e (patch) | |
tree | 5a7ea2c281ee34840ce6d4db5232707ff004f464 /.bashrc_cxx | |
parent | fix ShellCheck warnings (diff) | |
download | linux-home-8fec942ab9913a38423a4cfea37d29ea304ddd0e.tar.gz linux-home-8fec942ab9913a38423a4cfea37d29ea304ddd0e.zip |
code style
Diffstat (limited to '')
-rw-r--r-- | .bashrc_cxx | 208 |
1 files changed, 104 insertions, 104 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[@]}"}" ) |