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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dca3a0e863422640812a8eda3d02fac5c1581eb
4
- data.tar.gz: e89463ff2e335de7296fa66f25ce2a5265e20c8b
3
+ metadata.gz: a9838abe6d0993c89a86b4b5532928914b79e763
4
+ data.tar.gz: 0c913b3f4a295000f5aa95bc1c2f1752a5e8ecdc
5
5
  SHA512:
6
- metadata.gz: 70cd3855b98c7f2fec630dbd6d9981e429b6dcd14ce39f2d8920c75b08c85ff03160c33f3788645d10d2949e942af08bbb045851cf7a85490156f02fcba62a30
7
- data.tar.gz: be9ac7a4f9ef4fe2a9c222a2484e097c9d200a80e09b2c494c0b315a28c02354b16b777d2e8c4f9f8e28bb22f0302a85a93f9610400a773f55f4f1c4b40fe3ef
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 a single $ sign.
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(get_command(source))
24
+ execute_a_command(source)
25
25
  end
26
- rescue Interrupt, MyshExit
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(str)
31
- try_execute_command(str)
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}"
@@ -16,8 +16,9 @@ module Mysh
16
16
  my_id = self.object_id
17
17
  fail "Mysh variable looping error." if loop_check[my_id]
18
18
  loop_check[my_id] = self
19
-
20
19
  @value.preprocess
20
+ ensure
21
+ loop_check.delete(my_id)
21
22
  end
22
23
 
23
24
  #Get the source code of this variable.
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mysh
4
4
  #The version string of MY SHell.
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.1"
6
6
 
7
7
  #A brief summary of this gem.
8
8
  SUMMARY = "mysh -- a Ruby inspired command line shell."
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
@@ -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.0
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-14 00:00:00.000000000 Z
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: '0.8'
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: '0.8'
110
+ version: 0.8.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: vls
113
113
  requirement: !ruby/object:Gem::Requirement