Skip to content

Commit 43d33cf

Browse files
committed
Refactor shell scripts for consistent indentation and formatting
- Updated indentation from tabs to spaces in various scripts for better readability. - Ensured consistent use of spacing around operators and keywords. - Improved the clarity of comments and echo statements across multiple service scripts. - Adjusted function definitions and command invocations to follow a uniform style. - Enhanced the overall maintainability of the codebase by adhering to a consistent coding standard.
1 parent b90d065 commit 43d33cf

20 files changed

Lines changed: 548 additions & 530 deletions

File tree

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
echo "$HOME/.local/bin" >> $GITHUB_PATH
4949
5050
- name: Check shell formatting
51-
run: shfmt -i 2 -bn -ci -sr -d .
51+
run: shfmt -i 4 -bn -ci -sr -d .
5252

5353
lint:
5454
name: 📋 Linting & Validation

.vscode/settings.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"shellformat.effectiveLanguages": [
3+
"shellscript",
4+
"dockerfile",
5+
"dotenv",
6+
"hosts",
7+
"jvmoptions",
8+
"ignore",
9+
"gitignore",
10+
"properties",
11+
"spring-boot-properties",
12+
"azcli",
13+
"bats"
14+
],
15+
"shellformat.flag": "-i 4 -bn -ci -sr",
16+
"[shellscript]": {
17+
"editor.defaultFormatter": "foxundermoon.shell-format",
18+
"editor.formatOnSave": true,
19+
"editor.tabSize": 4,
20+
"editor.insertSpaces": true
21+
}
22+
}

common/help_ips.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88

99
# shellcheck disable=SC2148
1010
function lhs_network_get_public_ip_instruction() {
11-
echo "
11+
echo "
1212
dig +short myip.opendns.com @resolver1.opendns.com
1313
"
1414

1515
}
1616

1717
function lhs_network_get_private_ip_ranges_instruction() {
1818

19-
# shellcheck disable=SC2155
20-
local lhs_docs=$(
21-
cat <<-__EOF__
19+
# shellcheck disable=SC2155
20+
local lhs_docs=$(
21+
cat <<- __EOF__
2222
10.0.0.0 - 10.255.255.255 (10/8 prefix)
2323
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
2424
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
2525
__EOF__
26-
)
26+
)
2727

28-
echo "$lhs_docs"
28+
echo "$lhs_docs"
2929
}
3030

3131
function lhs_network_get_public_ip() {
32-
dig +short myip.opendns.com @resolver1.opendns.com
32+
dig +short myip.opendns.com @resolver1.opendns.com
3333
}
3434

3535
function lhs_network_tcp_traceroute() {
3636

37-
# https://www.redhat.com/sysadmin/traceroute-finding-meaning
38-
sudo tcptraceroute 8.8.8.8 443
37+
# https://www.redhat.com/sysadmin/traceroute-finding-meaning
38+
sudo tcptraceroute 8.8.8.8 443
3939
}

common/help_menu.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
#!/bin/bash
22

33
function lhs_help_helpful() {
4-
# Support both function function_name() { or function_name with prefix aws_bla_bla() {
5-
local lhs_functions
6-
lhs_functions=$(lhs_peco_helpful_function_list)
7-
local lhs_option=${1:-IgnoreCase}
8-
9-
# Use peco to filter and select from the list of helpful functions
10-
# LBUFFER contains the current command line buffer content
11-
# The selected function will be stored in BUFFER
12-
BUFFER=$(
13-
# shellcheck disable=SC2153
14-
echo "${lhs_functions}" | peco --query "$LBUFFER" --initial-filter "${lhs_option}"
15-
)
16-
17-
# shellcheck disable=SC2034
18-
CURSOR=$#BUFFER
4+
# Support both function function_name() { or function_name with prefix aws_bla_bla() {
5+
local lhs_functions
6+
lhs_functions=$(lhs_peco_helpful_function_list)
7+
local lhs_option=${1:-IgnoreCase}
8+
9+
# Use peco to filter and select from the list of helpful functions
10+
# LBUFFER contains the current command line buffer content
11+
# The selected function will be stored in BUFFER
12+
BUFFER=$(
13+
# shellcheck disable=SC2153
14+
echo "${lhs_functions}" | peco --query "$LBUFFER" --initial-filter "${lhs_option}"
15+
)
16+
17+
# shellcheck disable=SC2034
18+
CURSOR=$#BUFFER
1919

2020
}
2121

2222
function lhs_help_all() {
23-
# Support both function function_name() { or function_name with prefix aws_bla_bla() {
24-
# shellcheck disable=SC2155
25-
local lhs_functions
26-
local lhs_option
23+
# Support both function function_name() { or function_name with prefix aws_bla_bla() {
24+
# shellcheck disable=SC2155
25+
local lhs_functions
26+
local lhs_option
2727

28-
lhs_functions=$(lhs_peco_function_list)
29-
lhs_option=${1:-"${LHS_PECO_FILTER_TYPE}"}
28+
lhs_functions=$(lhs_peco_function_list)
29+
lhs_option=${1:-"${LHS_PECO_FILTER_TYPE}"}
3030

31-
# shellcheck disable=SC2034
32-
BUFFER=$(
33-
echo "${lhs_functions}" | peco --query "$LBUFFER" --initial-filter "${lhs_option}"
34-
)
31+
# shellcheck disable=SC2034
32+
BUFFER=$(
33+
echo "${lhs_functions}" | peco --query "$LBUFFER" --initial-filter "${lhs_option}"
34+
)
3535

36-
# shellcheck disable=SC2034
37-
CURSOR=$#BUFFER
36+
# shellcheck disable=SC2034
37+
CURSOR=$#BUFFER
3838

3939
}
4040

4141
function lhs_help_refresh() {
42-
lhs_peco_disable_input_cached
43-
lhs_peco_function_list >>/dev/null
44-
lhs_peco_helpful_function_list >>/dev/null
45-
lhs_peco_enable_input_cached
42+
lhs_peco_disable_input_cached
43+
lhs_peco_function_list >> /dev/null
44+
lhs_peco_helpful_function_list >> /dev/null
45+
lhs_peco_enable_input_cached
4646

4747
}

common/other.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

33
function lhs_help_install_macos_clipboard_instruction() {
4-
cat <<-_EOF_
4+
cat <<- _EOF_
55
Install clipy
66
Access Shift + command + v
77
_EOF_
88
}
99

1010
function lhs_help_install_macos_peco_instruction() {
11-
cat <<-_EOF_
11+
cat <<- _EOF_
1212
# Install peco
1313
brew install peco
1414
_EOF_
@@ -17,7 +17,7 @@ function lhs_help_install_macos_peco_instruction() {
1717

1818
function lhs_help_create_os_user_instruction() {
1919

20-
echo '
20+
echo '
2121
2222
visudo
2323
son.lam ALL=(ALL) ALL
@@ -40,6 +40,6 @@ function lhs_help_create_os_user_instruction() {
4040
}
4141

4242
function lhs_help_cache_disabled_all() {
43-
lhs_peco_disable_input_cached
44-
peco_aws_disable_input_cached
43+
lhs_peco_disable_input_cached
44+
peco_aws_disable_input_cached
4545
}

common/peco/other.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
# There ares some bugs, then I will overwrite it and use it in help_menu.sh of private-helpful-commandlines. # TODO Later (Fix latter, can't not get the function name - lhs_proj_rakkar_infra_aws_migrate_from_original_to_private_dns_record_for_dev)
44
function lhs_peco_function_list() {
5-
# Ignore private function
6-
local lhs_function_list_cmd="
5+
# Ignore private function
6+
local lhs_function_list_cmd="
77
find \"${LHS_HELPFUL_LOOKUP}\" \
88
-type d \( -name 'docs' -o -name 'snippets' -o -name '.git' \) -prune \
99
-o -type f -name '*.sh' -print \
1010
| grep -v main.sh | xargs cat | grep -v '^function.*private.*' \
1111
| grep -e '^function.*\(.+*\)' -e '^aws*\(.+*\)' -e '^peco*\(.+*\)' -e '^lhs*\(.+*\)' \
1212
| tr -d '(){' | awk -F ' ' '{ print (\$1==\"function\") ? \$2 : \$1}' | sort
1313
"
14-
# Cache in LHS_HELPFUL_LOOKUP_FUNCTIONS_CACHED_EXPIRED_TIME setting
15-
lhs_peco_commandline_input "${lhs_function_list_cmd}" "${LHS_HELPFUL_LOOKUP_CACHED}" "${LHS_HELPFUL_LOOKUP_FUNCTIONS_CACHED_EXPIRED_TIME}"
14+
# Cache in LHS_HELPFUL_LOOKUP_FUNCTIONS_CACHED_EXPIRED_TIME setting
15+
lhs_peco_commandline_input "${lhs_function_list_cmd}" "${LHS_HELPFUL_LOOKUP_CACHED}" "${LHS_HELPFUL_LOOKUP_FUNCTIONS_CACHED_EXPIRED_TIME}"
1616

1717
}
1818

1919
function lhs_peco_helpful_function_list() {
20-
local lhs_function_list_cmd="
20+
local lhs_function_list_cmd="
2121
find \"${HELPFUL_COMMANDLINES_SOURCE_SCRIPTS}\" \
2222
-type d \( -name 'docs' -o -name 'snippets' -o -name '.git' \) -prune \
2323
-o -type f -name '*.sh' -print \
2424
| grep -v main.sh | xargs cat | grep -e '^function.*\(.+*\)' -e '^aws*\(.+*\)' -e '^peco*\(.+*\)' -e '^lhs*\(.+*\)' \
2525
| tr -d '(){' | awk -F ' ' '{ print (\$1==\"function\") ? \$2 : \$1}' | sort
2626
"
2727

28-
# Cache without expired time
29-
lhs_peco_commandline_input "${lhs_function_list_cmd}" "${LHS_HELPFUL_LOOKUP_CACHED}" "0"
28+
# Cache without expired time
29+
lhs_peco_commandline_input "${lhs_function_list_cmd}" "${LHS_HELPFUL_LOOKUP_CACHED}" "0"
3030

3131
}

0 commit comments

Comments
 (0)