Skip to content

Commit 03a71a4

Browse files
committed
renaming of files and dirs to be more consistent
GSH_ROOT/bin => GSH_ROOT/scripts previous_commands.sh => fc-lnr.sh history_start.sh / history_clean.sh => alt_history_start.sh / alt_history_stop.sh realpath => readlink-f save_environment.sh => print_current_environment.sh
1 parent 057bae4 commit 03a71a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+123
-115
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tests-verbose: clean
6060
./"game shell (1).sh" -RDq -c 'gsh systemconfig; for _ in $$(seq 42); do gsh goal|cat; gsh test --abort; gsh auto --abort; done; gsh stat'
6161

6262
clean:
63-
rm -rf i18n/*~ locale gameshell.tgz gameshell.sh gameshell-save.sh bin/boxes-data.awk
63+
rm -rf i18n/*~ locale gameshell.tgz gameshell.sh gameshell-save.sh scripts/boxes-data.awk
6464
rm -rf .bin .config .sbin .var World
6565
rm -rf "game shell"*
6666

lib/bin_test.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
### test the various utilities in GSH_ROOT/bin/ directory
3+
### test the various utilities in GSH_ROOT/scripts/ directory
44

55
test_mktemp() (
66
if ! tmp=$(mktemp 2>/dev/null)
@@ -17,33 +17,33 @@ test_mktemp() (
1717
)
1818

1919

20-
test_realpath() (
20+
test_readlink_f() (
2121
tmp=${GSH_TMP:?Error: \$GSH_TMP not set}
2222
cd "$tmp"
2323
rm -f a b
2424

2525
touch a
26-
rpa=$(realpath ./a)
26+
rpa=$(readlink-f ./a)
2727
if [ -z "$rpa" ]
2828
then
29-
echo "Error: realpath returned the empty string." >&2
29+
echo "Error: readlink-f returned the empty string." >&2
3030
return 1
3131
fi
3232

3333
case "$rpa" in
34-
"$(realpath "$tmp")"* )
34+
"$(readlink-f "$tmp")"* )
3535
;;
3636
* )
37-
echo "Error: realpath didn't give an absolute path." >&2
37+
echo "Error: readlink-f didn't give an absolute path." >&2
3838
return 1
3939
;;
4040
esac
4141

4242
ln -s a b
43-
rpb=$(realpath b)
43+
rpb=$(readlink-f b)
4444
if [ "$rpa" != "$rpb" ]
4545
then
46-
echo "Error: realpath doesn't resolve symbolic links." >&2
46+
echo "Error: readlink-f doesn't resolve symbolic links." >&2
4747
return 1
4848
fi
4949

@@ -97,4 +97,4 @@ test_sign() (
9797
return 0
9898
)
9999

100-
test_mktemp && test_realpath && test_checksum && test_sign
100+
test_mktemp && test_readlink_f && test_checksum && test_sign

lib/gsh.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ __gsh_start() {
194194
then
195195
local env_before=$(mktemp)
196196
local env_after=$(mktemp)
197-
. save_environment.sh > "$env_before"
197+
. print_current_environment.sh > "$env_before"
198198
fi
199199

200200
mission_source "$MISSION_DIR/init.sh"
@@ -221,7 +221,7 @@ Aborting.")" >&2
221221

222222
if ! . mainshell.sh
223223
then
224-
. save_environment.sh > "$env_after"
224+
. print_current_environment.sh > "$env_after"
225225

226226
if ! cmp -s "$env_before" "$env_after"
227227
then

lib/gshrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export COLUMNS
2323
# choose appropriate pager
2424
unset PAGER
2525
tempfile=$(mktemp)
26-
echo "TEST" | "$GSH_ROOT/bin/pager" 2>"$tempfile" >/dev/null
26+
echo "TEST" | "$GSH_ROOT/scripts/pager" 2>"$tempfile" >/dev/null
2727
if [ -s "$tempfile" ]
2828
then
2929
export PAGER=more

lib/mission_source.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mission_source() {
4444
local _MISSION_DIR _TEXTDOMAIN _MISSION_NAME _PATH exit_status
4545
export MISSION_DIR TEXTDOMAIN MISSION_NAME
4646
_MISSION_DIR=$MISSION_DIR
47-
MISSION_DIR=$(dirname "$(realpath "$FILENAME")")
47+
MISSION_DIR=$(dirname "$(readlink-f "$FILENAME")")
4848
_TEXTDOMAIN=$TEXTDOMAIN
4949
TEXTDOMAIN=$(textdomainname "$MISSION_DIR")
5050
_MISSION_NAME=$MISSION_NAME
@@ -75,9 +75,9 @@ mission_source() {
7575

7676
# otherwise, record the environment (variables, functions and aliases)
7777
# before and after to echo a message when there are differences
78-
. save_environment.sh >"$env_before"
78+
. print_current_environment.sh >"$env_before"
7979
_MISSION_DIR=$MISSION_DIR
80-
MISSION_DIR=$(dirname "$(realpath "$FILENAME")")
80+
MISSION_DIR=$(dirname "$(readlink-f "$FILENAME")")
8181
_TEXTDOMAIN=$TEXTDOMAIN
8282
TEXTDOMAIN=$(textdomainname "$MISSION_DIR")
8383
_MISSION_NAME=$MISSION_NAME
@@ -90,7 +90,7 @@ mission_source() {
9090
MISSION_NAME=$_MISSION_NAME
9191
MISSION_DIR=$_MISSION_DIR
9292
PATH=$_PATH
93-
. save_environment.sh | grep -v "$MISSION_FN" > "$env_after"
93+
. print_current_environment.sh | grep -v "$MISSION_FN" > "$env_after"
9494

9595
if ! cmp -s "$env_before" "$env_after"
9696
then

lib/profile.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ export COLUMNS
3030
# putting $GSH_ROOT/bin first makes sure the local scripts are prefered over
3131
# system commands (realpath, seq, etc.). This is useful for testing, but
3232
# probably shouldn't be done for "stable" releases.
33-
PATH="$GSH_ROOT/bin":$PATH
34-
# PATH=$PATH:"$GSH_ROOT/bin"
33+
PATH="$GSH_ROOT/scripts":$PATH
34+
# PATH=$PATH:"$GSH_ROOT/scripts"
3535

missions/basic/01_cd_tower/check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
goal=$(realpath "$(eval_gettext "\$GSH_HOME/Castle/Main_tower/First_floor/Second_floor/Top_of_the_tower")")
4-
current=$(realpath "$PWD")
3+
goal=$(readlink-f "$(eval_gettext "\$GSH_HOME/Castle/Main_tower/First_floor/Second_floor/Top_of_the_tower")")
4+
current=$(readlink-f "$PWD")
55

66
if [ "$goal" = "$current" ]
77
then

missions/basic/02_cd.._cellar/check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
goal=$(realpath "$(eval_gettext "\$GSH_HOME/Castle/Cellar")")
4-
current=$(realpath "$PWD")
3+
goal=$(readlink-f "$(eval_gettext "\$GSH_HOME/Castle/Cellar")")
4+
current=$(readlink-f "$PWD")
55

66
if [ "$goal" = "$current" ]
77
then

missions/basic/03_cd_HOME_throne/auto.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
66

@@ -11,4 +11,4 @@ add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
1111
add_cmd gsh check
1212
gsh check
1313

14-
. history_clean.sh
14+
. alt_history_stop.sh

missions/basic/03_cd_HOME_throne/check.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# this should be POSIX compliant, but debian's sh (dash) doesn't have fc!
44

55
_mission_check() {
6-
goal=$(realpath "$(eval_gettext "\$GSH_HOME/Castle/Main_building/Throne_room")")
7-
current=$(realpath "$PWD")
6+
goal=$(readlink-f "$(eval_gettext "\$GSH_HOME/Castle/Main_building/Throne_room")")
7+
current=$(readlink-f "$PWD")
88

9-
ppc=$(. previous_commands.sh | sed -n '2p;3q')
9+
ppc=$(. fc-lnr.sh | sed -n '2p;3q')
1010

1111
# FIXME: also accept other commands to go back to the starting point?
1212
# FIXME: add an error message

missions/basic/03_cd_HOME_throne/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
# add dummy commands to avoid error messages
66
add_cmd dummy1
@@ -30,4 +30,4 @@ add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
3030
add_cmd gsh check
3131
gsh assert check true
3232

33-
. history_clean.sh
33+
. alt_history_stop.sh

missions/finding_files_maze/01_ls_cd/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p "$GSH_CHEST"
66
_mission_init() (
77
if ! command -v generate_maze.sh >/dev/null
88
then
9-
DUMMY_MISSION=$(realpath "$MISSION_DIR/../00_shared")
9+
DUMMY_MISSION=$(readlink-f "$MISSION_DIR/../00_shared")
1010
DUMMY_MISSION=${DUMMY_MISSION#$GSH_MISSIONS/}
1111
echo "$(eval_gettext "Dummy mission '\$DUMMY_MISSION' is required for mission \$MISSION_NB (\$MISSION_NAME).")" >&2
1212
return 1

missions/finding_files_maze/02_tree/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p "$GSH_CHEST"
66
_mission_init() (
77
if ! command -v generate_maze.sh >/dev/null
88
then
9-
DUMMY_MISSION=$(realpath "$MISSION_DIR/../00_shared")
9+
DUMMY_MISSION=$(readlink-f "$MISSION_DIR/../00_shared")
1010
DUMMY_MISSION=${DUMMY_MISSION#$GSH_MISSIONS/}
1111
echo "$(eval_gettext "Dummy mission '\$DUMMY_MISSION' is required for mission \$MISSION_NB (\$MISSION_NAME).")" >&2
1212
return 1

missions/finding_files_maze/03_find_1/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p "$GSH_CHEST"
66
_mission_init() (
77
if ! command -v generate_maze.sh >/dev/null
88
then
9-
DUMMY_MISSION=$(realpath "$MISSION_DIR/../00_shared")
9+
DUMMY_MISSION=$(readlink-f "$MISSION_DIR/../00_shared")
1010
DUMMY_MISSION=${DUMMY_MISSION#$GSH_MISSIONS/}
1111
echo "$(eval_gettext "Dummy mission '\$DUMMY_MISSION' is required for mission \$MISSION_NB (\$MISSION_NAME).")" >&2
1212
return 1

missions/finding_files_maze/04_find_2/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p "$GSH_CHEST"
66
_mission_init() (
77
if ! command -v generate_maze.sh >/dev/null
88
then
9-
DUMMY_MISSION=$(realpath "$MISSION_DIR/../00_shared")
9+
DUMMY_MISSION=$(readlink-f "$MISSION_DIR/../00_shared")
1010
DUMMY_MISSION=${DUMMY_MISSION#$GSH_MISSIONS/}
1111
echo "$(eval_gettext "Dummy mission '\$DUMMY_MISSION' is required for mission \$MISSION_NB (\$MISSION_NAME).")" >&2
1212
return 1

missions/finding_files_maze/05_find_xargs_grep/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mkdir -p "$GSH_CHEST"
66
_mission_init() (
77
if ! command -v generate_maze.sh >/dev/null
88
then
9-
DUMMY_MISSION=$(realpath "$MISSION_DIR/../00_shared")
9+
DUMMY_MISSION=$(readlink-f "$MISSION_DIR/../00_shared")
1010
DUMMY_MISSION=${DUMMY_MISSION#$GSH_MISSIONS/}
1111
echo "$(eval_gettext "Dummy mission '\$DUMMY_MISSION' is required for mission \$MISSION_NB (\$MISSION_NAME).")" >&2
1212
return 1

missions/intermediate/02_alias_journal/check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ _mission_check() {
2222
# alias journal="nano journal.txt"
2323
# used from the Chest
2424
local target_path
25-
target_path="$(cd / ; eval "${cmd/$EDITOR/realpath}" 2>/dev/null)"
26-
if [ "$target_path" = "$(realpath "$GSH_CHEST/$(gettext "journal").txt" 2>/dev/null)" ]
25+
target_path="$(cd / ; eval "${cmd/$EDITOR/readlink-f}" 2>/dev/null)"
26+
if [ "$target_path" = "$(readlink-f "$GSH_CHEST/$(gettext "journal").txt" 2>/dev/null)" ]
2727
then
2828
return 0
2929
else

missions/intermediate/03_tab_spider_lair/check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _mission_check() (
77

88

99
lair="$(find "$(eval_gettext '$GSH_HOME/Castle/Cellar')" -type d -name ".$(gettext "Lair_of_the_spider_queen")*")"
10-
if [ "$(realpath "$(pwd)")" != "$(realpath "$lair")" ]
10+
if [ "$(readlink-f "$(pwd)")" != "$(readlink-f "$lair")" ]
1111
then
1212
echo "$(gettext "You are not in the queen spider lair!")"
1313
return 1
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
add_cmd "xeyes"
66
add_cmd "xeyes &"
77
xeyes &
88
add_cmd gsh check
99
gsh check
1010

11-
. history_clean.sh
11+
. alt_history_stop.sh

missions/intermediate/04_bg_xeyes/check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# fc in specified in POSIX, but debian's sh doesn't implement it!
44

55
_mission_check() {
6-
if ! (. previous_commands.sh | head -n 4 | grep -qx "[[:blank:]]*xeyes[[:blank:]]*")
6+
if ! (. fc-lnr.sh | head -n 4 | grep -qx "[[:blank:]]*xeyes[[:blank:]]*")
77
then
88
echo "$(gettext "Have you run the 'xeyes' command directly?")"
99
ps -e | awk '/xeyes/ {print $1}' | xargs kill -9 2> /dev/null

missions/intermediate/04_bg_xeyes/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
add_cmd "xeyes"
66
add_cmd "xeyes &"
@@ -29,5 +29,5 @@ gsh assert check true
2929

3030
ps -e | awk '/xeyes/ {print $1}' | xargs kill -9 2> /dev/null
3131

32-
. history_clean.sh
32+
. alt_history_stop.sh
3333

missions/permissions/01_chmod_x_dir_king_quarter/check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
dir=$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room/Kings_quarter')
44

5-
if [ "$(realpath "$(pwd)" 2>/dev/null)" = "$(realpath "$dir" 2>/dev/null)" ]
5+
if [ "$(readlink-f "$(pwd)" 2>/dev/null)" = "$(readlink-f "$dir" 2>/dev/null)" ]
66
then
77
unset dir
88
true

missions/permissions/01_chmod_x_dir_king_quarter/clean.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ case "$GSH_LAST_ACTION" in
77
:
88
;;
99
*)
10-
_PWD="$(realpath $(pwd) 2>/dev/null)"
11-
if [ -n "$_PWD" ] && [ "$_PWD" = "$(realpath "$king_quarter" 2>/dev/null)" ]
10+
_PWD="$(readlink-f $(pwd) 2>/dev/null)"
11+
if [ -n "$_PWD" ] && [ "$_PWD" = "$(readlink-f "$king_quarter" 2>/dev/null)" ]
1212
then
1313
cd ..
1414
fi

missions/permissions/01_chmod_x_dir_king_quarter/init.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _mission_init() (
77
return 1
88
fi
99

10-
[ "$(realpath "$(pwd)")" = "$(realpath "$dir")" ] && cd ..
10+
[ "$(readlink-f "$(pwd)")" = "$(readlink-f "$dir")" ] && cd ..
1111

1212
dir=$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room/Kings_quarter')
1313
chmod -x "$dir"

missions/permissions/03_chmod_rw_file_dir_throne_room/clean.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ case "$GSH_LAST_ACTION" in
77
:
88
;;
99
*)
10-
_PWD="$(realpath $(pwd) 2>/dev/null)"
11-
if [ -n "$_PWD" ] && [ "$_PWD" = "$(realpath "$safe" 2>/dev/null)" ]
10+
_PWD="$(readlink-f $(pwd) 2>/dev/null)"
11+
if [ -n "$_PWD" ] && [ "$_PWD" = "$(readlink-f "$safe" 2>/dev/null)" ]
1212
then
1313
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
1414
fi
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
cd "$(eval_gettext '$GSH_HOME/Mountain/Cave')"
66

@@ -10,4 +10,4 @@ add_cmd head -n 6 "$(gettext "Book_of_potions")/$(gettext "page")_07"
1010
add_cmd gsh check
1111
gsh check
1212

13-
. history_clean.sh
13+
. alt_history_stop.sh

missions/pipe_intro_book_of_potions/01_head/check.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
_mission_check() (
44
cave="$(eval_gettext '$GSH_HOME/Mountain/Cave')"
55

6-
pc=$(. previous_commands.sh | head -n1)
6+
pc=$(. fc-lnr.sh | head -n1)
77

8-
goal=$(realpath "$cave")
9-
current=$(realpath "$PWD")
8+
goal=$(readlink-f "$cave")
9+
current=$(readlink-f "$PWD")
1010

1111
if ! diff -q "$cave/$(gettext 'Book_of_potions')" "$GSH_TMP/book_of_potions" >/dev/null
1212
then

missions/pipe_intro_book_of_potions/01_head/test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
cd "$(eval_gettext '$GSH_HOME/Mountain/Cave')"
66

@@ -22,4 +22,4 @@ add_cmd "head -n 6 $(gettext "Book_of_potions")/$(gettext "page")_07"
2222
add_cmd gsh check
2323
gsh assert check false
2424

25-
. history_clean.sh
25+
. alt_history_stop.sh
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
. history_start.sh
3+
. alt_history_start.sh
44

55
cd "$(eval_gettext '$GSH_HOME/Mountain/Cave')"
66

@@ -10,4 +10,4 @@ add_cmd tail -n 9 "$(gettext "Book_of_potions")/$(gettext "page")_12"
1010
add_cmd gsh check
1111
gsh check
1212

13-
. history_clean.sh
13+
. alt_history_stop.sh

0 commit comments

Comments
 (0)