mysh 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -8
- data/lib/mysh/process.rb +4 -4
- data/lib/mysh/shell_variables/shell_variable_keeper.rb +2 -1
- data/lib/mysh/sources/console.rb +16 -0
- data/lib/mysh/version.rb +1 -1
- data/mysh.gemspec +1 -1
- data/tests/my_shell_tests.rb +11 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9838abe6d0993c89a86b4b5532928914b79e763
|
4
|
+
data.tar.gz: 0c913b3f4a295000f5aa95bc1c2f1752a5e8ecdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853099d5554d1a06cec3aa83f16e86cd4d001bb2b90dfcbccb26857486753c5f4370306ce513d3892f00206b2116f9a259adbaf5988284e2a250e7ad05047488
|
7
|
+
data.tar.gz: 9b5e6af59deb7716d4f3f11da57753c6f1174b38acf17bce8f35fff7dc628855cddcd200fe1a5e77dc1043e001aa31215176f01739f539bf52c5108af1acc9c7
|
data/README.md
CHANGED
@@ -347,7 +347,7 @@ In mysh, variables are kept that control the behavior of the shell. This simple
|
|
347
347
|
command is used to set, delete, and display these variables. The basic method
|
348
348
|
for setting a variable is:
|
349
349
|
|
350
|
-
$name=value
|
350
|
+
set $name=value
|
351
351
|
|
352
352
|
Where:
|
353
353
|
* name is a word matching the regex: /[a-z][a-z0-9_]*/. Note: lower case only.
|
@@ -355,17 +355,14 @@ Where:
|
|
355
355
|
|
356
356
|
To erase the value of a variable, use:
|
357
357
|
|
358
|
-
$name=
|
358
|
+
set $name=
|
359
359
|
|
360
360
|
To display the name/value of a variable, use:
|
361
361
|
|
362
|
-
$name
|
362
|
+
set $name
|
363
363
|
|
364
|
-
To display all variable names/values use just enter
|
365
|
-
|
366
|
-
As an escapement, the string $$ maps to a single $.
|
367
|
-
|
368
|
-
Some variables that are used in mysh are:
|
364
|
+
To display all variable names/values use just enter "set". As an escapement,
|
365
|
+
the string $$ maps to a single $. Some variables that are used in mysh are:
|
369
366
|
|
370
367
|
Variable | Description
|
371
368
|
------------|--------------------------------------------
|
data/lib/mysh/process.rb
CHANGED
@@ -21,14 +21,14 @@ module Mysh
|
|
21
21
|
#Process commands from a source.
|
22
22
|
def self.process_source(source)
|
23
23
|
until source.eoi? do
|
24
|
-
execute_a_command(
|
24
|
+
execute_a_command(source)
|
25
25
|
end
|
26
|
-
rescue
|
26
|
+
rescue MyshExit
|
27
27
|
end
|
28
28
|
|
29
29
|
#Execute a single line of input and handle exceptions.
|
30
|
-
def self.execute_a_command(
|
31
|
-
try_execute_command(
|
30
|
+
def self.execute_a_command(source)
|
31
|
+
try_execute_command(get_command(source))
|
32
32
|
|
33
33
|
rescue Interrupt, StandardError, ScriptError => err
|
34
34
|
puts "Error #{err.class}: #{err}"
|
data/lib/mysh/sources/console.rb
CHANGED
@@ -15,11 +15,27 @@ module Mysh
|
|
15
15
|
def get_command
|
16
16
|
puts MNV[:pre_prompt] if MNV.key?(:pre_prompt)
|
17
17
|
get(prompt: MNV[:prompt] + '>')
|
18
|
+
rescue MiniReadlinePLE => err
|
19
|
+
retry unless handle_get_error(err, :prompt)
|
20
|
+
exit
|
18
21
|
end
|
19
22
|
|
20
23
|
#Get additional lines of continued commands.
|
21
24
|
def get_command_extra(str)
|
22
25
|
get(prompt: MNV[:post_prompt] + '\\', prefix: str[0])
|
26
|
+
rescue MiniReadlinePLE => err
|
27
|
+
retry unless handle_get_error(err, :post_prompt)
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
# Handle a readline error
|
32
|
+
def handle_get_error(err, selector)
|
33
|
+
puts "Error #{err.class}: #{err}"
|
34
|
+
puts err.backtrace if MNV[:debug]
|
35
|
+
|
36
|
+
MNV[selector].empty?
|
37
|
+
ensure
|
38
|
+
MNV[selector] = ""
|
23
39
|
end
|
24
40
|
|
25
41
|
#Have we reached the end of input?
|
data/lib/mysh/version.rb
CHANGED
data/mysh.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'rdoc', "~> 5.0"
|
31
31
|
spec.add_development_dependency 'reek', "~> 4.5"
|
32
32
|
|
33
|
-
spec.add_runtime_dependency 'mini_readline', "~> 0.8"
|
33
|
+
spec.add_runtime_dependency 'mini_readline', "~> 0.8.1"
|
34
34
|
spec.add_runtime_dependency 'vls', "~> 0.4.1"
|
35
35
|
spec.add_runtime_dependency 'in_array', "~> 0.1.8"
|
36
36
|
end
|
data/tests/my_shell_tests.rb
CHANGED
@@ -235,4 +235,15 @@ class MyShellTester < Minitest::Test
|
|
235
235
|
assert_equal("test\\foo\\bar.rb".to_std_spec, "test/foo/bar.rb")
|
236
236
|
end
|
237
237
|
|
238
|
+
def test_recursion_detection
|
239
|
+
MNV[:rec_test_one] = "one"
|
240
|
+
assert_equal("one one", "$rec_test_one $rec_test_one".preprocess)
|
241
|
+
|
242
|
+
MNV[:rec_test_too] = "$rec_test_too".preprocess
|
243
|
+
assert_raises { "$rec_test_too".preprocess }
|
244
|
+
|
245
|
+
MNV[:rec_test_two] = "$rec_test_one $rec_test_one"
|
246
|
+
assert_equal("one one", "$rec_test_two".preprocess)
|
247
|
+
end
|
248
|
+
|
238
249
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.8.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.8.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: vls
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|