Browse code

Added some comments to note the surprisingly old modification timestamps of the scripts "platz", "noteplatz", and "apsk-equate-platzes". A good reminder that even very simple, basic programs that have been unchanged for literally years can still be incredibly useful. (Except I don't think I ever used apsk-equate-platzes at all yet.) Also made minor cosmetic changes to the source code - added infodecor and navdecor comments, and changed some indentation.

https://apollia.org/gitlist/Apollia-Jargon.git

Apollia authored on10/04/2021 08:25:11
Showing1 changed files
... ...
@@ -4,6 +4,10 @@
4 4
 #
5 5
 #
6 6
 # by Apollia - http://apollia.com/
7
+#
8
+#
9
+# 03:59:35 10/04/2021.  Before this update, last modified: 2018-05-25 01:47:11 -0400
10
+
7 11
 
8 12
 
9 13
 readonly Command_Name="apsk-get-platz"
... ...
@@ -29,10 +33,9 @@ readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
29 33
 		readonly Follpath____Config="$Follpath____This_Script/0000-Config"
30 34
 
31 35
 
32
-readonly Fillepath____Folderpath_of_Platz_Trails="$Follpath____Config/Folderpath of Platz Trails"
33
-
34
-Follpath____Platz_Trails=$(cat "$Fillepath____Folderpath_of_Platz_Trails")
35
-result_code="$?"
36
+			readonly Fillepath____Folderpath_of_Platz_Trails="$Follpath____Config/Folderpath of Platz Trails"
37
+				Follpath____Platz_Trails=$(cat "$Fillepath____Folderpath_of_Platz_Trails")
38
+					result_code="$?"
36 39
 
37 40
 
38 41
 if [ "$result_code" != 0 ]
... ...
@@ -212,15 +215,21 @@ readonly Follpath____Platz_Path_Notes="$Follpath____Platz_Trails/Platz -> Path N
212 215
 readonly Fillepath____Platz_Note="$Follpath____Platz_Path_Notes/$Platz"
213 216
 
214 217
 Platz_Path=$(cat "$Fillepath____Platz_Note"  2>&1 /dev/null )
215
-result_code="$?"
218
+	result_code="$?"
216 219
 
217 220
 if [ "$result_code" != 0 ]
218 221
 then
219 222
 	echo "Found no path assigned to this platz:
220 223
 
221 224
 $Platz"
225
+
226
+
227
+	#!!!!
222 228
 	exit 3
223 229
 fi
224 230
 
225 231
 echo "$Platz_Path"
232
+
233
+
234
+#!!!!
226 235
 exit 0
227 236
\ No newline at end of file
Browse code

Added some line breaks to the error message about "no path assigned to this platz".

Apollia authored on05/25/2018 05:48:27
Showing1 changed files
... ...
@@ -216,7 +216,9 @@ result_code="$?"
216 216
 
217 217
 if [ "$result_code" != 0 ]
218 218
 then
219
-	echo "Found no path assigned to this platz: $Platz"
219
+	echo "Found no path assigned to this platz:
220
+
221
+$Platz"
220 222
 	exit 3
221 223
 fi
222 224
 
Browse code

Now "platz" and "noteplatz" accept two switches: --namespace and --basename.

And the future behavior of --namespace hasn't been implemented
yet, since I'd rather work on other stuff at the moment.

Various other small changes. Rearranged and decluttered a bit.

And, soon before 22:21:48 05/24/2018, accidentally appended
my next commit to this old commit, so now both "platz" and
"noteplatz" have been updated.

Apollia authored on05/25/2018 01:33:58
Showing1 changed files
... ...
@@ -6,11 +6,15 @@
6 6
 # by Apollia - http://apollia.com/
7 7
 
8 8
 
9
+readonly Command_Name="apsk-get-platz"
10
+readonly Short_Command_Name="platz"
9 11
 
10 12
 if [ -z "$1" ]
11 13
 then
12
-	echo "$0: Arg #1 must be the platz you want to retrieve the path of."
14
+	echo "$Command_Name: Arg #1 must be the name (and optionally namespace) of a platz you want to retrieve the path of."
13 15
 	
16
+	
17
+	#!!!!
14 18
 	exit 1
15 19
 fi
16 20
 
... ...
@@ -18,7 +22,6 @@ fi
18 22
 # it doesn't contain any path badchars or commas.
19 23
 
20 24
 
21
-readonly Platz="$1"
22 25
 
23 26
 readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
24 27
 	readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
... ...
@@ -36,19 +39,174 @@ if [ "$result_code" != 0 ]
36 39
 then
37 40
 	echo
38 41
 	echo
39
-	echo "$0 error: Aborting, because it wasn't possible to retrieve the config file containing the folderpath of this app's notes:
42
+	echo "$Command_Name error: Aborting, because it wasn't possible to retrieve the config file containing the folderpath of this app's notes:
40 43
 
41 44
 	$Fillepath____Folderpath_of_Platz_Trails"
42
-	exit 3
45
+	
46
+	
47
+	#!!!!
48
+	exit 2
43 49
 fi
44 50
 
45 51
 
46 52
 if [ ! -d "$Follpath____Platz_Trails" ]
47 53
 then
48
-	echo "$0: No platzes have been noted so far!"
49
-	exit 2
54
+	echo "$Command_Name: No platzes have been noted so far!"
55
+	
56
+	
57
+	#!!!!
58
+	exit 3
50 59
 fi
51 60
 
61
+
62
+
63
+############
64
+# Function
65
+Parse_Switch_Args()
66
+{
67
+	
68
+#-------------------------------------------------------------------------------
69
+#
70
+# Slightly modified getopt code from:
71
+#
72
+#http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash/29754866#29754866
73
+#
74
+# Thanks to the authors, especially for the tip about using eval to properly handle quoting!
75
+
76
+	count_of_args_before_parsing_switches="$#"
77
+	
78
+	#echo "count_of_args_before_parsing_switches: $count_of_args_before_parsing_switches"
79
+	
80
+
81
+	PARSED_SWITCHES=$(getopt --alternative --options b:,h,n: --longoptions basename:,help,namespace: --name "$Short_Command_Name" -- "$@" )
82
+
83
+	if [ $? != 0 ]
84
+	then
85
+		# then getopt has complained about wrong arguments to stdout
86
+		echo
87
+		Help_Message
88
+		
89
+		
90
+		#!!!!
91
+		exit 3
92
+	fi
93
+
94
+
95
+	eval set -- "$PARSED_SWITCHES"
96
+	# Use eval with "$PARSED_SWITCHES" to properly handle the quoting.
97
+	
98
+	Arg____Platz_Basename_or_Complete_Platz=""
99
+	Arg____Platz_Namespace=""
100
+	
101
+
102
+	for arg
103
+	do
104
+		#echo "Arg: $arg"
105
+		case "$arg" in
106
+			
107
+			-b|--basename)
108
+				Arg____Platz_Basename_or_Complete_Platz="$2"
109
+				shift
110
+				shift
111
+				;;
112
+			-n|--namespace)
113
+				Arg____Platz_Namespace="$2"
114
+				shift
115
+				shift
116
+				;;
117
+				
118
+			-h|--help)
119
+				Help_Message
120
+				
121
+				
122
+				#!!!!
123
+				exit 0
124
+				;;
125
+			
126
+			--)
127
+			#	echo "Dashes!"
128
+				shift
129
+				;;
130
+		esac
131
+	done
132
+
133
+	Positional_Args=( "$@" )
134
+	count_of_positional_args="$#"
135
+	
136
+	count_of_args_after_parsing_switches="$#"
137
+	
138
+	#echo "count_of_args_after_parsing_switches: $count_of_args_after_parsing_switches"
139
+	#echo "count_of_positional_args: $count_of_positional_args"
140
+	
141
+}
142
+readonly -f Parse_Switch_Args
143
+
144
+# End of
145
+# Function
146
+############
147
+
148
+
149
+
150
+############
151
+# Function
152
+Parse_Positional_Args()
153
+{
154
+	# 14:13:20 04/27/2018.  If any of these conflict with switches, these win.
155
+
156
+	ARG1=${@:$OPTIND:1}
157
+	ARG2=${@:$OPTIND+1:1}
158
+	#~ ARG3=${@:$OPTIND+2:1}
159
+	#~ ARG4=${@:$OPTIND+3:1}
160
+	#~ ARG5=${@:$OPTIND+4:1}
161
+	
162
+	# 11:30 07/24/2016.  The below are basically abbreviated if/then statements.
163
+	#
164
+	# If ARG1 is not empty, then Arg____File gets set to $ARG1.  Etc.
165
+
166
+	[ ! -z "$ARG1" ] && Arg____Platz_Basename_or_Complete_Platz="$ARG1"
167
+	[ ! -z "$ARG2" ] && Arg____Platz_Namespace="$ARG2"
168
+
169
+}
170
+readonly -f Parse_Positional_Args
171
+
172
+# End of
173
+# Function
174
+############
175
+
176
+
177
+declare -a Positional_Args
178
+
179
+Parse_Switch_Args "$@"
180
+
181
+#printf 'pos arg %s\n' "${Positional_Args[@]}"
182
+
183
+Parse_Positional_Args "${Positional_Args[@]}"
184
+
185
+
186
+# 21:17:50 05/24/2018.  Arg #1 can be just the basename of a platz,
187
+# or it can be a complete platz - "Namespace - Basename".
188
+#
189
+# (Though actually, even just a basename alone can qualify as a complete
190
+# platz, because platzes aren't required to have a namespace.)
191
+#
192
+#
193
+# If Arg #2 is provided, then, to assemble the complete platz string,
194
+# Arg #2 will be prepended to Arg #1, followed by " - ".
195
+
196
+
197
+# 21:28:49 05/24/2018.  For now, since I'd rather keep working on
198
+# APSK Initializer Stage 2, nothing fancy is going to happen with
199
+# namespaces.
200
+
201
+
202
+if [ ! -z "$Arg____Platz_Namespace" ]
203
+then
204
+	Platz="$Arg____Platz_Namespace - $Arg____Platz_Basename_or_Complete_Platz"
205
+else
206
+	Platz="$Arg____Platz_Basename_or_Complete_Platz"
207
+fi
208
+
209
+
52 210
 readonly Follpath____Platz_Path_Notes="$Follpath____Platz_Trails/Platz -> Path Notes"
53 211
 
54 212
 readonly Fillepath____Platz_Note="$Follpath____Platz_Path_Notes/$Platz"
Browse code

Removed some clutter from "platz".

How small and simple it is! A pity I have to make it more complicated.

Apollia authored on05/25/2018 00:03:33
Showing1 changed files
... ...
@@ -4,8 +4,7 @@
4 4
 #
5 5
 #
6 6
 # by Apollia - http://apollia.com/
7
-#
8
-# Completed 
7
+
9 8
 
10 9
 
11 10
 if [ -z "$1" ]
... ...
@@ -22,31 +21,16 @@ fi
22 21
 readonly Platz="$1"
23 22
 
24 23
 readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
25
-readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
26
-
27
-readonly Follpath____Config="$Follpath____This_Script/0000-Config"
24
+	readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
28 25
 
29
-#~ readonly Fillepath____Folderpath_of_Platz_Notes="$Follpath____Config/Folderpath of Platz Notes"
26
+		readonly Follpath____Config="$Follpath____This_Script/0000-Config"
30 27
 
31
-#~ Follpath____Platz_Notes=$(cat "$Fillepath____Folderpath_of_Platz_Notes")
32
-#~ result_code="$?"
33
-#~ 
34
-#~ if [ "$result_code" != 0 ]
35
-#~ then
36
-	#~ echo
37
-	#~ echo
38
-	#~ echo "$0 error: Aborting, because it wasn't possible to retrieve the config file containing the folderpath of platz notes:
39
-#~ 
40
-	#~ $Fillepath____Folderpath_of_Platz_Notes"
41
-	#~ exit 2
42
-#~ fi
43 28
 
44 29
 readonly Fillepath____Folderpath_of_Platz_Trails="$Follpath____Config/Folderpath of Platz Trails"
45 30
 
46 31
 Follpath____Platz_Trails=$(cat "$Fillepath____Folderpath_of_Platz_Trails")
47 32
 result_code="$?"
48 33
 
49
-#echo "Follpath____Platz_Trails: $Follpath____Platz_Trails"
50 34
 
51 35
 if [ "$result_code" != 0 ]
52 36
 then
Browse code

Renamed apsk-get-platz-path to "platz", and renamed apsk-note-platz-path to "noteplatz", since those are the names I usually use for them.

Apollia authored on05/24/2018 23:56:43
Showing1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,82 @@
1
+#!/bin/bash
2
+
3
+#   Script:      apsk-get-platz
4
+#
5
+#
6
+# by Apollia - http://apollia.com/
7
+#
8
+# Completed 
9
+
10
+
11
+if [ -z "$1" ]
12
+then
13
+	echo "$0: Arg #1 must be the platz you want to retrieve the path of."
14
+	
15
+	exit 1
16
+fi
17
+
18
+# July 28, 2017, 1:30 PM.  Should valicheck the platz to make sure
19
+# it doesn't contain any path badchars or commas.
20
+
21
+
22
+readonly Platz="$1"
23
+
24
+readonly Fillepath____This_Script=$(realpath "${BASH_SOURCE[0]}")
25
+readonly Follpath____This_Script=$(dirname "$Fillepath____This_Script")
26
+
27
+readonly Follpath____Config="$Follpath____This_Script/0000-Config"
28
+
29
+#~ readonly Fillepath____Folderpath_of_Platz_Notes="$Follpath____Config/Folderpath of Platz Notes"
30
+
31
+#~ Follpath____Platz_Notes=$(cat "$Fillepath____Folderpath_of_Platz_Notes")
32
+#~ result_code="$?"
33
+#~ 
34
+#~ if [ "$result_code" != 0 ]
35
+#~ then
36
+	#~ echo
37
+	#~ echo
38
+	#~ echo "$0 error: Aborting, because it wasn't possible to retrieve the config file containing the folderpath of platz notes:
39
+#~ 
40
+	#~ $Fillepath____Folderpath_of_Platz_Notes"
41
+	#~ exit 2
42
+#~ fi
43
+
44
+readonly Fillepath____Folderpath_of_Platz_Trails="$Follpath____Config/Folderpath of Platz Trails"
45
+
46
+Follpath____Platz_Trails=$(cat "$Fillepath____Folderpath_of_Platz_Trails")
47
+result_code="$?"
48
+
49
+#echo "Follpath____Platz_Trails: $Follpath____Platz_Trails"
50
+
51
+if [ "$result_code" != 0 ]
52
+then
53
+	echo
54
+	echo
55
+	echo "$0 error: Aborting, because it wasn't possible to retrieve the config file containing the folderpath of this app's notes:
56
+
57
+	$Fillepath____Folderpath_of_Platz_Trails"
58
+	exit 3
59
+fi
60
+
61
+
62
+if [ ! -d "$Follpath____Platz_Trails" ]
63
+then
64
+	echo "$0: No platzes have been noted so far!"
65
+	exit 2
66
+fi
67
+
68
+readonly Follpath____Platz_Path_Notes="$Follpath____Platz_Trails/Platz -> Path Notes"
69
+
70
+readonly Fillepath____Platz_Note="$Follpath____Platz_Path_Notes/$Platz"
71
+
72
+Platz_Path=$(cat "$Fillepath____Platz_Note"  2>&1 /dev/null )
73
+result_code="$?"
74
+
75
+if [ "$result_code" != 0 ]
76
+then
77
+	echo "Found no path assigned to this platz: $Platz"
78
+	exit 3
79
+fi
80
+
81
+echo "$Platz_Path"
82
+exit 0
0 83
\ No newline at end of file