Skip to content

Commit 90dfee3

Browse files
williamspatrickgkeishin
authored andcommitted
beautysh: re-format
beautysh is enabled in the openbmc-build-scripts on Bash/Zsh/POSIX-sh files to have a consistent formatting. Re-run the formatter on the whole repository. Signed-off-by: Patrick Williams <[email protected]> Change-Id: I584c76da2eb35af2177a97d5cd4b882f9881fb80
1 parent 12e3352 commit 90dfee3

File tree

12 files changed

+629
-630
lines changed

12 files changed

+629
-630
lines changed

bin/gen_list.sh

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# example.
77

88
if ! test "${default_delim+defined}" ; then
9-
readonly default_delim=" "
9+
readonly default_delim=" "
1010
fi
1111

1212
# Performance note: It is important for these functions to run quickly. One way to increase their speed is
@@ -15,104 +15,104 @@ fi
1515
# the functions. The cost of this is that it makes the functions slightly more difficult to read.
1616

1717

18-
function add_list_element {
19-
# local list_element="${1}"
20-
# local list_name="${2}"
21-
# local delim="${3:-${default_delim}}"
22-
# local position="${4:-back}"
18+
function add_list_element() {
19+
# local list_element="${1}"
20+
# local list_name="${2}"
21+
# local delim="${3:-${default_delim}}"
22+
# local position="${4:-back}"
2323

24-
# Add the list_element to the list named in list_name.
24+
# Add the list_element to the list named in list_name.
2525

26-
# Description of argument(s):
27-
# list_element The list element to be added.
28-
# list_name The name of the list to be modified.
29-
# delim The delimiter used to separate list elements.
30-
# position Indicates the position in the list where the new element should be added
31-
# ("front"/"back").
26+
# Description of argument(s):
27+
# list_element The list element to be added.
28+
# list_name The name of the list to be modified.
29+
# delim The delimiter used to separate list elements.
30+
# position Indicates the position in the list where the new element should be added
31+
# ("front"/"back").
3232

33-
if [ -z "${!2}" ] ; then
34-
# The list is blank. Simply assign it the list_element value and return.
35-
eval "${2}=\"${1}\""
36-
return
37-
fi
33+
if [ -z "${!2}" ] ; then
34+
# The list is blank. Simply assign it the list_element value and return.
35+
eval "${2}=\"${1}\""
36+
return
37+
fi
3838

39-
if [ "${4:-back}" == "back" ] ; then
40-
# Append the list_element to the back of the list and return.
41-
eval "${2}=\"\${${2}}\${3-${default_delim}}\${1}\""
42-
return
43-
fi
39+
if [ "${4:-back}" == "back" ] ; then
40+
# Append the list_element to the back of the list and return.
41+
eval "${2}=\"\${${2}}\${3-${default_delim}}\${1}\""
42+
return
43+
fi
4444

45-
# Append the list_element to the front of the list and return.
46-
eval "${2}=\"\${1}\${3-${default_delim}}\${${2}}\""
45+
# Append the list_element to the front of the list and return.
46+
eval "${2}=\"\${1}\${3-${default_delim}}\${${2}}\""
4747

4848
}
4949

5050

51-
function remove_list_element {
52-
# local list_element="${1}"
53-
# local list_name="${2}"
54-
local delim="${3:-${default_delim}}"
51+
function remove_list_element() {
52+
# local list_element="${1}"
53+
# local list_name="${2}"
54+
local delim="${3:-${default_delim}}"
5555

56-
# Remove all occurrences of list_element from the list named in list_name.
56+
# Remove all occurrences of list_element from the list named in list_name.
5757

58-
# Description of argument(s):
59-
# list_element The list element to be removed.
60-
# list_name The name of the list to be modified.
61-
# delim The delimiter used to separate list elements.
58+
# Description of argument(s):
59+
# list_element The list element to be removed.
60+
# list_name The name of the list to be modified.
61+
# delim The delimiter used to separate list elements.
6262

63-
local __rle_new_list__="${!2}"
63+
local __rle_new_list__="${!2}"
6464

65-
# Special case: The list contains one element which matches the specified list element:
66-
if [ "${1}" == "${__rle_new_list__}" ] ; then
67-
eval ${2}=\"\"
68-
return
69-
fi
65+
# Special case: The list contains one element which matches the specified list element:
66+
if [ "${1}" == "${__rle_new_list__}" ] ; then
67+
eval ${2}=\"\"
68+
return
69+
fi
7070

71-
# Replace all occurrences of list_element that are bounded by the delimiter on both sides.
72-
__rle_new_list__="${__rle_new_list__//${delim}${1}${delim}/${delim}}"
73-
# Replace list_item if it occurs at the beginning of the string and is bounded on the right by the
74-
# delimiter.
75-
__rle_new_list__="${__rle_new_list__#${1}${delim}}"
76-
# Replace list_item if it occurs at the end of the string and is bounded on the left by the delimiter.
77-
__rle_new_list__="${__rle_new_list__%${delim}${1}}"
71+
# Replace all occurrences of list_element that are bounded by the delimiter on both sides.
72+
__rle_new_list__="${__rle_new_list__//${delim}${1}${delim}/${delim}}"
73+
# Replace list_item if it occurs at the beginning of the string and is bounded on the right by the
74+
# delimiter.
75+
__rle_new_list__="${__rle_new_list__#${1}${delim}}"
76+
# Replace list_item if it occurs at the end of the string and is bounded on the left by the delimiter.
77+
__rle_new_list__="${__rle_new_list__%${delim}${1}}"
7878

79-
# Set caller's variable to new value.
80-
eval ${2}=\"\${__rle_new_list__}\"
79+
# Set caller's variable to new value.
80+
eval ${2}=\"\${__rle_new_list__}\"
8181

8282
}
8383

8484

85-
function cleanup_path_slashes {
86-
local var_name="${1}" ; shift
85+
function cleanup_path_slashes() {
86+
local var_name="${1}" ; shift
8787

88-
# For the variable named in var_name, replace all multiple-slashes with single slashes and strip any
89-
# trailing slash.
88+
# For the variable named in var_name, replace all multiple-slashes with single slashes and strip any
89+
# trailing slash.
9090

91-
# Description of argument(s):
92-
# var_name The name of the variable whose contents are to be changed.
91+
# Description of argument(s):
92+
# var_name The name of the variable whose contents are to be changed.
9393

94-
local cmd_buf
94+
local cmd_buf
9595

96-
cmd_buf="${var_name}=\$(echo \"\${${var_name}}\" | sed -re 's#[/]+#/#g' -e 's#/\$##g')"
97-
eval "${cmd_buf}"
96+
cmd_buf="${var_name}=\$(echo \"\${${var_name}}\" | sed -re 's#[/]+#/#g' -e 's#/\$##g')"
97+
eval "${cmd_buf}"
9898

9999
}
100100

101101

102-
function remove_path {
103-
local dir_path="${1}" ; shift
104-
local path_var="${1:-PATH}" ; shift
102+
function remove_path() {
103+
local dir_path="${1}" ; shift
104+
local path_var="${1:-PATH}" ; shift
105105

106-
# Remove all occurrences of dir_path from the path variable named in path_var.
106+
# Remove all occurrences of dir_path from the path variable named in path_var.
107107

108-
# Note that this function will remove extraneous slashes from the elements of path_var.
108+
# Note that this function will remove extraneous slashes from the elements of path_var.
109109

110-
# Description of argument(s):
111-
# dir_path The directory to be removed from the path variable.
112-
# path_var The name of a variable containing directory paths separated by colons.
110+
# Description of argument(s):
111+
# dir_path The directory to be removed from the path variable.
112+
# path_var The name of a variable containing directory paths separated by colons.
113113

114-
cleanup_path_slashes dir_path || return 1
115-
cleanup_path_slashes ${path_var} || return 1
116-
remove_list_element "${dir_path}" "${path_var}" : || return 1
114+
cleanup_path_slashes dir_path || return 1
115+
cleanup_path_slashes ${path_var} || return 1
116+
remove_list_element "${dir_path}" "${path_var}" : || return 1
117117

118118
}

bin/gen_setup.sh

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,43 @@
1313
shopt -s extglob
1414

1515

16-
function get_pgm_path_info {
17-
local program_path_var="${1:-program_path}" ; shift
18-
local program_name_var="${1:-program_name}" ; shift
19-
local program_dir_path_var="${1:-program_dir_path}" ; shift
20-
local follow_links="${1:-0}" ; shift
21-
22-
# Determine the program path, name and dir path and assign them to the variables indicated by the caller.
23-
24-
# Description of argument(s):
25-
# program_path_var The name of the variable to receive the program path.
26-
# program_name_var The name of the variable to receive the program name.
27-
# program_dir_path_var The name of the variable to receive the program dir path.
28-
# follow_links If the program running is actually a link to another file, use that file
29-
# when calculating the above values.
30-
31-
local _spn_loc_program_path_="${0}"
32-
33-
# The program name is the program path minus all characters up to and including the first slash.
34-
local _spn_loc_program_name_=${_spn_loc_program_path_##*/}
35-
# The program dir path is the program path minus everything from the last slash to the end of the string.
36-
local _spn_loc_program_dir_path_=${_spn_loc_program_path_%${_spn_loc_program_name_}}
37-
38-
# If program dir path does not start with a slash then it is relative. Convert it to absolute.
39-
if [ "${_spn_loc_program_dir_path_:0:1}" != "/" ] ; then
40-
_spn_loc_program_dir_path_="$(readlink -f ${_spn_loc_program_dir_path_})/"
41-
# Re-assemble the parts into program path variable.
42-
_spn_loc_program_path_="${_spn_loc_program_dir_path_}${_spn_loc_program_name_}"
43-
fi
44-
45-
if (( follow_links )) ; then
46-
_spn_loc_program_path_=$(readlink -f ${_spn_loc_program_path_})
47-
# Re-calculate program_name in case it is different now.
48-
_spn_loc_program_name_=${_spn_loc_program_path_##*/}
49-
fi
50-
51-
# Set caller's variables.
52-
cmd_buf="${program_path_var}=\"\${_spn_loc_program_path_}\" ; ${program_name_var}=\"\${_spn_loc_program_name_}\" ; ${program_dir_path_var}=\"\${_spn_loc_program_dir_path_}\""
53-
eval "${cmd_buf}"
16+
function get_pgm_path_info() {
17+
local program_path_var="${1:-program_path}" ; shift
18+
local program_name_var="${1:-program_name}" ; shift
19+
local program_dir_path_var="${1:-program_dir_path}" ; shift
20+
local follow_links="${1:-0}" ; shift
21+
22+
# Determine the program path, name and dir path and assign them to the variables indicated by the caller.
23+
24+
# Description of argument(s):
25+
# program_path_var The name of the variable to receive the program path.
26+
# program_name_var The name of the variable to receive the program name.
27+
# program_dir_path_var The name of the variable to receive the program dir path.
28+
# follow_links If the program running is actually a link to another file, use that file
29+
# when calculating the above values.
30+
31+
local _spn_loc_program_path_="${0}"
32+
33+
# The program name is the program path minus all characters up to and including the first slash.
34+
local _spn_loc_program_name_=${_spn_loc_program_path_##*/}
35+
# The program dir path is the program path minus everything from the last slash to the end of the string.
36+
local _spn_loc_program_dir_path_=${_spn_loc_program_path_%${_spn_loc_program_name_}}
37+
38+
# If program dir path does not start with a slash then it is relative. Convert it to absolute.
39+
if [ "${_spn_loc_program_dir_path_:0:1}" != "/" ] ; then
40+
_spn_loc_program_dir_path_="$(readlink -f ${_spn_loc_program_dir_path_})/"
41+
# Re-assemble the parts into program path variable.
42+
_spn_loc_program_path_="${_spn_loc_program_dir_path_}${_spn_loc_program_name_}"
43+
fi
44+
45+
if (( follow_links )) ; then
46+
_spn_loc_program_path_=$(readlink -f ${_spn_loc_program_path_})
47+
# Re-calculate program_name in case it is different now.
48+
_spn_loc_program_name_=${_spn_loc_program_path_##*/}
49+
fi
50+
51+
# Set caller's variables.
52+
cmd_buf="${program_path_var}=\"\${_spn_loc_program_path_}\" ; ${program_name_var}=\"\${_spn_loc_program_name_}\" ; ${program_dir_path_var}=\"\${_spn_loc_program_dir_path_}\""
53+
eval "${cmd_buf}"
5454

5555
}

0 commit comments

Comments
 (0)