Skip to content

Commit

Permalink
shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
temptemp3 committed May 12, 2021
1 parent 1c1bb6f commit 70c3234
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 62 deletions.
2 changes: 1 addition & 1 deletion clipboy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ clipboy ${@}
## generated by create-stub2.sh v0.1.1
## on Thu, 08 Nov 2018 12:51:06 +0900
## see <https://github.com/temptemp3/sh2>
##################################################
##################################################
42 changes: 25 additions & 17 deletions commands/190114-clipboy-make.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#!/bin/bash
## clipboy-make
## version 0.0.2 - source create-stub2
## version 0.0.3 - shellcheck
##################################################
create-stub2() { ${SH2}/${FUNCNAME}.sh ${@} ; }
clipboy-make-command() { { local function_name ; function_name="${1}" ; }
# shellcheck disable=SC2128
create-stub2() { "${SH2}/${FUNCNAME}.sh" "${@}" ; }
on-missing-function-name() {
test "${function_name}" || {
clipboy-say "What command Me makes?"
read candidate_command
read -r candidate_command
function_name=${candidate_command}
}
}
# shellcheck disable=SC2154,SC2086
clipboy-make-command() { { local function_name ; function_name="${1}" ; }
on-missing-function-name
test ! "${function_name}" || {
test -f "$( dirname ${0} )/${function_name}.sh" || {
test -f "$( dirname "${0}" )/${function_name}.sh" || {
clipboy-say "Me makes ${function_name} command"
{
{
Expand Down Expand Up @@ -51,16 +56,16 @@ clipboy-${program}() { { local command_type ; command_type="\$( echo \${1} | cut
esac
}
##################################################
## generated by $( basename ${0} ) v$( grep -e 'version' ${0} | head -n 1 | cut '-f3' '-d ' )
## generated by $( basename "${0}" ) v$( grep -e 'version' "${0}" | head -n 1 | cut '-f3' '-d ' )
## on $( date --rfc-2822 )
## see <https://github.com/temptemp3/sh2>
##################################################
EOF
}
declare -xf create-stub-generate-stub-head
declare -xf create-stub-generate-stub-entry
create-stub2 ${function_name}
} | tee $( dirname ${0} )/commands/$( date +%y%m%d )-clipboy-${function_name}.sh
create-stub2 "${function_name}"
} | tee "$( dirname ${0} )/commands/$( date +%y%m%d )-clipboy-${function_name}.sh"
} &>/dev/null
}
}
Expand All @@ -73,16 +78,17 @@ clipboy-make-function() { { local function_name ; function_name="${1}" ; }
test "${single}" = "true"
}
path-to-script() {
# shellcheck disable=SC2015
if-single && {
echo $( if-dated )${function_name}.sh
echo "$( if-dated )${function_name}.sh"
true
} || {
echo ${function_name}.sh/$( if-dated )${function_name}.sh
echo "${function_name}.sh/$( if-dated )${function_name}.sh"
}
}
local dated
local single
for arg in ${@}
for arg in "${@}"
do
case ${arg} in
--dated) dated="true" ;;
Expand All @@ -106,8 +112,8 @@ clipboy-make-function() { { local function_name ; function_name="${1}" ; }
EOF
}
declare -xf create-stub-generate-stub-head
create-stub2 ${function_name} \
| tee $( path-to-script )
create-stub2 "${function_name}" \
| tee "$( path-to-script )"
}
}
clipboy-make-default() {
Expand All @@ -119,16 +125,18 @@ clipboy-make-help() {
}
unset -f clipboy-make-help
unset -f clipboy-make-default
# shellcheck disable=SC2119
clipboy-make
}
# shellcheck disable=SC2120
clipboy-make() {
{ local command_type ; command_type="$( echo ${1} | cut '-d:' '-f2' )" ; }
case "$( declare -f ${FUNCNAME}-${command_type} )" in
{ local command_type ; command_type=$( echo "${1}" | cut '-d:' '-f2' ) ; }
case $( declare -f "${FUNCNAME}-${command_type}" ) in
"") {
${FUNCNAME}-default
"${FUNCNAME}-default"
} ;;
*) {
${FUNCNAME}-${command_type} ${@:2}
"${FUNCNAME}-${command_type}" "${@:2}"
} ;;
esac
}
Expand Down
18 changes: 10 additions & 8 deletions commands/200226-clipboy-make-subcommand.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
## clipboy-make-subcommand
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-make-subcommand() { { local function_name ; function_name="${1}" ; }
set -v -x
# shellcheck disable=SC2154
function-body-script() {
cat << EOF
. \$( dirname \${0} )/scripts/$( date +%y%m%d )-${program}.sh \${@}
Expand All @@ -15,22 +15,23 @@ EOF
true
EOF
}
# shellcheck disable=SC2128
function-body() {
set -v -x
test ! -f "${scripts}/$( date +%y%m%d )-${program}.sh" || {
echo "using script" 1>&2
${FUNCNAME}-script
"${FUNCNAME}-script"
return
}
cecho "using true" 1>&2
${FUNCNAME}-true
"${FUNCNAME}-true"
}
test "${function_name}" || {
clipboy-say "What subcommand Me makes?"
read candidate_command
read -r candidate_command
function_name=${candidate_command}
}
test ! "${function_name}" || {
# shellcheck disable=SC2086
test -f "$( dirname ${0} )/${function_name}.sh" || {
clipboy-say "Me makes ${function_name} subcommand"
{
Expand Down Expand Up @@ -60,9 +61,10 @@ EOF
declare -xf function-body
declare -xf function-body-script
declare -xf function-body-true
declare -x scripts="$( dirname ${0} )/scripts"
declare -x scripts
scripts="$( dirname ${0} )/scripts"
create-stub2 ${function_name}
} | tee $( dirname ${0} )/commands/$( date +%y%m%d )-clipboy-${function_name}.sh
} | tee "$( dirname ${0} )/commands/$( date +%y%m%d )-clipboy-${function_name}.sh"
} &>/dev/null
}
}
Expand Down
10 changes: 6 additions & 4 deletions commands/200304-clipboy-make-script.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/bash
## make-script
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-make-script() { { local function_name ; function_name="${1}" ; }
test "${function_name}" || {
clipboy-say "What script Me makes?"
read candidate_command
read -r candidate_command
function_name=${candidate_command}
}
test ! "${function_name}" || {
# shellcheck disable=SC2086
test -f "$( dirname ${0} )/${function_name}.sh" || {
clipboy-say "Me makes ${function_name} script"
{
{
# shellcheck disable=SC2154
create-stub-generate-stub-head() {
cat << EOF
#!/bin/bash
Expand All @@ -38,10 +40,10 @@ EOF
declare -xf create-stub-generate-stub-head
declare -xf create-stub-generate-stub-entry
test -d "$( dirname ${0} )/scripts" || {
cecho yellow $( mkdir -pv ${_} )
cecho yellow "$( mkdir -pv ${_} )"
}
create-stub2 ${function_name}
} | tee $( dirname ${0} )/scripts/$( date +%y%m%d )-${function_name}.sh
} | tee "$( dirname ${0} )/scripts/$( date +%y%m%d )-${function_name}.sh"
} &>/dev/null
}
}
Expand Down
5 changes: 3 additions & 2 deletions commands/200305-clipboy-store-get.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
## store-get
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-store-get() {
. $( dirname ${0} )/scripts/200305-store-get.sh ${@}
# shellcheck disable=SC1091,SC2086
. "$( dirname ${0} )/scripts/200305-store-get.sh" "${@}"
}
##################################################
## generated by create-stub2.sh v0.1.2
Expand Down
5 changes: 3 additions & 2 deletions commands/200305-clipboy-store-list.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
## store-list
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-store-list() {
. $( dirname ${0} )/scripts/200305-store-list.sh ${@}
# shellcheck disable=SC1091,SC2086
. "$( dirname ${0} )/scripts/200305-store-list.sh" "${@}"
}
##################################################
## generated by create-stub2.sh v0.1.2
Expand Down
5 changes: 3 additions & 2 deletions commands/200305-clipboy-store-set.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
## store-set
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-store-set() {
. $( dirname ${0} )/scripts/200305-store-set.sh ${@}
# shellcheck disable=SC1091,SC2086
. "$( dirname ${0} )/scripts/200305-store-set.sh" "${@}"
}
##################################################
## generated by create-stub2.sh v0.1.2
Expand Down
17 changes: 9 additions & 8 deletions commands/200305-clipboy-store.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
## store
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
command-name-third-person-present() {
echo "${command_name}s"
Expand All @@ -12,19 +12,20 @@ clipboy-store-help() {
clipboy-store() {
commands
}
unset -f clipboy-${command_name}-help
unset -f clipboy-${command_name}-default
clipboy-${command_name}
unset -f "clipboy-${command_name}-help"
unset -f "clipboy-${command_name}-default"
"clipboy-${command_name}"
}
clipboy-store() { { local command_type ; command_type="$( echo ${1} | cut '-d:' '-f2' )" ; }
clipboy-store() { { local command_type ; command_type=$( echo "${1}" | cut '-d:' '-f2' ) ; }
local command_name
command_name="store"
case "$( declare -f ${FUNCNAME}-${command_type} )" in
# shellcheck disable=SC2128
case $( declare -f "${FUNCNAME}-${command_type}" ) in
"") {
${FUNCNAME}-default
"${FUNCNAME}-default"
} ;;
*) {
${FUNCNAME}-${command_type} ${@:2}
"${FUNCNAME}-${command_type}" "${@:2}"
} ;;
esac
}
Expand Down
5 changes: 3 additions & 2 deletions commands/201012-clipboy-install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
## install
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
clipboy-install() {
. $( dirname ${0} )/scripts/201012-install.sh ${@}
# shellcheck disable=SC1091,SC2086
. "$( dirname ${0} )/scripts/201012-install.sh" "${@}"
}
##################################################
## generated by create-stub2.sh v0.1.2
Expand Down
9 changes: 5 additions & 4 deletions scripts/200305-store-get.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash
## store-get
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
. ${SH2}/store.sh
# shellcheck disable=SC1091
. "${SH2}/store.sh"
_store-get() { { local key ; key="${1}" ; local value ; value="${2}" ; }
init-store-silent
store get ${key} ${value}
store get "${key}" "${value}"
}
##################################################
_store-get ${@}
_store-get "${@}"
##################################################
## generated by create-stub2.sh v0.1.2
## on Thu, 05 Mar 2020 21:14:50 +0900
Expand Down
12 changes: 7 additions & 5 deletions scripts/200305-store-list.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/bin/bash
## store-list
## version 0.0.2 - w/o xargs
## version 0.0.3 - shellcheck
##################################################
. ${SH2}/store.sh
# shellcheck disable=SC1091
. "${SH2}/store.sh"
_store-list() {
init-store-silent
local key
for key in ${!store[@]}
# shellcheck disable=SC2154
for key in "${!store[@]}"
do
echo ${key}: ${store[${key}]}
echo "${key}: ${store[${key}]}"
done
}
##################################################
_store-list ${@}
_store-list
##################################################
## generated by create-stub2.sh v0.1.2
## on Thu, 05 Mar 2020 21:33:08 +0900
Expand Down
9 changes: 5 additions & 4 deletions scripts/200305-store-set.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
## store-set
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
. ${SH2}/store.sh
# shellcheck disable=SC1091
. "${SH2}/store.sh"
_store-set() { { local key ; key="${1}" ; local value ; value="${2}" ; }
init-store-silent
store set ${key} ${value}
store set "${key}" "${value}"
store persist
}
##################################################
_store-set ${@}
_store-set "${@}"
##################################################
## generated by create-stub2.sh v0.1.2
## on Thu, 05 Mar 2020 20:51:05 +0900
Expand Down
6 changes: 3 additions & 3 deletions scripts/201012-install.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
## install
## version 0.0.1 - initial
## version 0.0.2 - shellcheck
##################################################
_install() {
test -f "clipboy.sh" || { true ; return ; }
{
cat << EOF
$( basename $( pwd ) )() {
$( basename "$( pwd )" )() {
bash $( pwd )/clipboy.sh \${@}
}
EOF
} >> ~/.bashrc
}
##################################################
_install ${@}
_install
##################################################
## generated by create-stub2.sh v0.1.2
## on Mon, 12 Oct 2020 23:18:51 +1100
Expand Down

0 comments on commit 70c3234

Please sign in to comment.