Skip to content

Commit febf183

Browse files
committed
fix: More error messages print to standard error
1 parent 4a6659e commit febf183

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

pkg/bin/basalt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ readlinkf_posix() {
3434
}
3535

3636
if [ "$0" != "${BASH_SOURCE[0]}" ]; then
37-
printf '%s\n' "Error: basalt: Script must not be sourced"
37+
printf '%s\n' "Error: basalt: Script must not be sourced" >&2
3838
return 1
3939
fi
4040

pkg/bin/basalt-package-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ readlinkf_posix() {
3434
}
3535

3636
if [ "$0" != "${BASH_SOURCE[0]}" ]; then
37-
printf '%s\n' "Error: basalt-package-init: Script must not be sourced"
37+
printf '%s\n' "Error: basalt: Script must not be sourced" >&2
3838
return 1
3939
fi
4040

pkg/share/scripts/basalt-package-init.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
basalt.package-init() {
77
if [ -z "$BASALT_GLOBAL_REPO" ]; then
8-
printf '%s\n' "Error: basalt.package-init: Variable '\$BASALT_GLOBAL_REPO' is empty" >&2
8+
printf '%s\n' "Error: basalt: Variable '\$BASALT_GLOBAL_REPO' is empty" >&2
99
exit 1
1010
fi
1111

1212
if [ ! -f "$BASALT_GLOBAL_REPO/pkg/src/public/basalt-global.sh" ]; then
13-
printf '%s\n' "Error: basalt.package-init: Failed to find file 'basalt-global.sh' in '\$BASALT_GLOBAL_REPO'" >&2
13+
printf '%s\n' "Error: basalt: Failed to find file 'basalt-global.sh' in '\$BASALT_GLOBAL_REPO'" >&2
1414
exit 1
1515
fi
1616
# shellcheck source=../../../pkg/src/public/basalt-global.sh
1717
source "$BASALT_GLOBAL_REPO/pkg/src/public/basalt-global.sh"
1818

1919
if [ ! -f "$BASALT_GLOBAL_REPO/pkg/src/public/basalt-package.sh" ]; then
20-
printf '%s\n' "Error: basalt.package-init: Failed to find file 'basalt-package.sh' in '\$BASALT_GLOBAL_REPO'" >&2
20+
printf '%s\n' "Error: basalt: Failed to find file 'basalt-package.sh' in '\$BASALT_GLOBAL_REPO'" >&2
2121
exit 1
2222
fi
2323
# shellcheck source=../../../pkg/src/public/basalt-package.sh
@@ -32,18 +32,18 @@ basalt.package-init() {
3232
local __basalt_target=
3333
__basalt_target=$(readlink "$__basalt_file")
3434
if ! cd "${__basalt_target%/*}"; then
35-
printf '%s\n' "Error: basalt.package-init: Could not cd to '${__basalt_target%/*}'" >&2
35+
printf '%s\n' "Error: basalt: Could not cd to '${__basalt_target%/*}'" >&2
3636
exit 1
3737
fi
3838
else
3939
if ! cd "${__basalt_file%/*}"; then
40-
printf '%s\n' "Error: basalt.package-init: Could not cd to '${__basalt_file%/*}'" >&2
40+
printf '%s\n' "Error: basalt: Could not cd to '${__basalt_file%/*}'" >&2
4141
exit 1
4242
fi
4343
fi
4444

4545
if ! cd "$__old_cd"; then
46-
printf '%s\n' "Error: basalt.package-init: Could not cd back to '$__old_cd'" >&2
46+
printf '%s\n' "Error: basalt: Could not cd back to '$__old_cd'" >&2
4747
exit 1
4848
fi
4949

pkg/src/commands/basalt-global-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ basalt-global-init() {
1616
local basalt_global_repo=
1717
if [ -L "$0" ]; then
1818
if ! basalt_global_repo=$(readlink -f "$0"); then
19-
printf '%s\n' "printf '%s\n' \"Error: basalt-package-init: Invocation of readlink failed\""
19+
printf '%s\n' "printf '%s\n' \"Error: basalt-package-init: Invocation of readlink failed\" >&2"
2020
printf '%s\n' 'exit 1'
2121
fi
2222
basalt_global_repo=${basalt_global_repo%/*}

pkg/src/public/basalt-global.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ basalt.load() {
3737
return
3838
;;
3939
-*)
40-
printf '%s\n' "Error: basalt.load: Flag '$arg' not recognized"
40+
printf '%s\n' "Error: basalt: Flag '$arg' not recognized" >&2
4141
return 1
4242
;;
4343
esac done
4444

4545
if (($# == 0)); then
4646
# WET (gamma)
47-
printf '%s\n' "Error: basalt.load: Must specify arguments
47+
printf '%s\n' "Error: basalt: Must specify arguments >&2
4848
4949
Usage:
5050
basalt.load [flags] <package> <file>
@@ -71,7 +71,7 @@ Pass '--help' for more info"
7171
local __basalt_file="${2:-}"
7272

7373
if [ -z "$__basalt_pkg_path" ]; then
74-
printf '%s\n' "Error: basalt.load: Missing package as first parameter"
74+
printf '%s\n' "Error: basalt: Missing package as first parameter" >&2
7575
if [ "$__basalt_flag_global" = 'yes' ]; then
7676
return 1
7777
else
@@ -95,7 +95,7 @@ Pass '--help' for more info"
9595
fi
9696

9797
if ((${#__basalt_pkg_path_full_array[@]} > 1)); then
98-
printf '%s\n' "Error: basalt.load: Multiple versions of the package '$__basalt_pkg_path' exists"
98+
printf '%s\n' "Error: basalt: Multiple versions of the package '$__basalt_pkg_path' exists" >&2
9999

100100
if [ "$__basalt_flag_global" = 'yes' ]; then
101101
return 1
@@ -120,9 +120,9 @@ Pass '--help' for more info"
120120

121121
local regex="^[^/]+/[^/]+$"
122122
if [[ "$__basalt_pkg_path" =~ $regex ]]; then
123-
printf '%s\n' "Error: basalt.load: Package '$__basalt_pkg_path' is not a valid. It must include the website domain"
123+
printf '%s\n' "Error: basalt: Package '$__basalt_pkg_path' is not a valid. It must include the website domain" >&2
124124
else
125-
printf '%s\n' "Error: basalt.load: Package '$__basalt_pkg_path' is not installed $__basalt_str"
125+
printf '%s\n' "Error: basalt: Package '$__basalt_pkg_path' is not installed $__basalt_str" >&2
126126
fi
127127

128128
if [ "$__basalt_flag_global" = 'yes' ]; then
@@ -133,7 +133,7 @@ Pass '--help' for more info"
133133
fi
134134

135135
if [ ! -f "$__basalt_pkg_path_full/$__basalt_file" ]; then
136-
printf '%s\n' "Error: basalt.load: File '$__basalt_file' not found in package '$__basalt_pkg_path'"
136+
printf '%s\n' "Error: basalt: File '$__basalt_file' not found in package '$__basalt_pkg_path'"f >&2
137137
if [ "$__basalt_flag_global" = 'yes' ]; then
138138
return 1
139139
else

pkg/src/public/basalt-package.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ basalt.package-load() {
77
local __basalt_shopt_nullglob=
88

99
if [ -z "${BASALT_PACKAGE_DIR:-}" ]; then
10-
printf '%s\n' "Error: basalt.package-load: Variable '\$BASALT_PACKAGE_DIR' is empty" >&2
10+
printf '%s\n' "Error: basalt: Variable '\$BASALT_PACKAGE_DIR' is empty" >&2
1111
exit 1
1212
fi
1313

1414
# These checks always ensure the generated files are in sync the 'basalt.toml'
1515
if [ ! -f "$BASALT_PACKAGE_DIR/.basalt/generated/done.sh" ]; then
16-
printf '%s\n' "Error: basalt.package-load: Command 'basalt install' must be ran again in '$BASALT_PACKAGE_DIR'" >&2
16+
printf '%s\n' "Error: basalt: Command 'basalt install' must be ran again in '$BASALT_PACKAGE_DIR'" >&2
1717
exit 1
1818
fi
1919

@@ -22,7 +22,7 @@ basalt.package-load() {
2222
basalt_file_last_modified_at=$(stat --format '%Y' "$BASALT_PACKAGE_DIR/basalt.toml")
2323
done_file_last_modified_at=$(stat --format '%Y' "$BASALT_PACKAGE_DIR/.basalt/generated/done.sh")
2424
if ((basalt_file_last_modified_at >= done_file_last_modified_at)); then # '>=' so automated 'basalt install' work on fast computers
25-
printf '%s\n' "Error: basalt.package-load: Command 'basalt install' must be ran again in '$BASALT_PACKAGE_DIR'" >&2
25+
printf '%s\n' "Error: basalt: Command 'basalt install' must be ran again in '$BASALT_PACKAGE_DIR'" >&2
2626
exit 1
2727
fi
2828

@@ -52,7 +52,7 @@ basalt.package-load() {
5252

5353
if [ -f "$__basalt_package.basalt/generated/source_all.sh" ]; then
5454
if BASALT_PACKAGE_DIR=$__basalt_package source "$__basalt_package.basalt/generated/source_all.sh"; then :; else
55-
printf '%s\n' "Error: basalt.package-load: Could not successfully source 'source_all.sh'" >&2
55+
printf '%s\n' "Error: basalt: Could not successfully source 'source_all.sh'" >&2
5656
return $?
5757
fi
5858
fi
@@ -74,7 +74,7 @@ basalt.package-load() {
7474

7575
if [ -f "$__basalt_package.basalt/generated/source_all.sh" ]; then
7676
if BASALT_PACKAGE_DIR=$__basalt_package source "$__basalt_package.basalt/generated/source_all.sh"; then :; else
77-
printf '%s\n' "Error: basalt.package-load: Could not successfully source 'source_all.sh'" >&2
77+
printf '%s\n' "Error: basalt: Could not successfully source 'source_all.sh'" >&2
7878
return $?
7979
fi
8080
fi

pkg/src/util/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ init.get_basalt_package_dir() {
3838
3939
printf '%s' "$PWD"
4040
); then
41-
printf '%s\n' "Error: basalt.package-init: Could not find basalt.toml" >&2
41+
printf '%s\n' "Error: basalt: Could not find basalt.toml" >&2
4242
exit 1
4343
fi
4444
}

0 commit comments

Comments
 (0)