ruby-shell 3.6.16 → 3.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +33 -28
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e133cdb364d88a5e82942a136ffd6a284105553a5e367bc5415e4623b1715ef
4
- data.tar.gz: e712cf81e8ffccebadfb579272892d54617da2e59e53a95fab02b5e6766a5a9f
3
+ metadata.gz: 2e9ecc77e9137be0869ab5108ca168b9af1fe7482f7c48db56d222381f3e0c2b
4
+ data.tar.gz: ffb83039ed726fdc1484e9c4d283525205dc39cd8a346c981005da8f14c3e5ac
5
5
  SHA512:
6
- metadata.gz: f3d81facd0b334b13a4112a17c02aa43e0364844d1405d45e3d989ef2122d24ea0dad9ebf80a86bfa1840fd0d1f1e56c2cddf1fe0c01590aa9feb8df764bc88f
7
- data.tar.gz: 7cf717175c6319230ab76586a02d065196e41a51b0e429a26d16bd5dd37ef3c037262a89f59697b4c31b7ad149664e32d8c19cbc9ff6d5581fa6d378463ed421
6
+ metadata.gz: a5bd6cc37c73511c6267b246c86048f55a48bb6054d9e2242b958f5d6a164a81d04c090b6c0ff053afa84e4ac64fcac2b4e36cae11926f45f7553af1461a27ee
7
+ data.tar.gz: abe9d8a5fcb1738492c99301c2f2171b4abb5450a4c24f79294b2eebe98a12e7962557e13d0bd79f068423d970223ea4af94358f6f7d40a577af81315efee2e3
data/bin/rsh CHANGED
@@ -8,7 +8,7 @@
8
8
  # Web_site: http://isene.com/
9
9
  # Github: https://github.com/isene/rsh
10
10
  # License: Public domain
11
- @version = "3.6.15" # Fix config persistence bugs in .rshrc
11
+ @version = "3.6.18" # Fix nick deletion and hyphenated command handling
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -388,38 +388,39 @@ def getstr # A custom Readline-like function
388
388
  lift = false
389
389
  right = false
390
390
 
391
- # Clear from cmd_row down (handles wrapped lines from previous iteration)
392
- @c.row(@cmd_row)
393
- @c.col(1)
394
- @c.clear_screen_down
395
-
396
- # Always reprint prompt + command text
397
- print @prompt_last_line
398
- print cmd_check(@history[0])
391
+ # Cache syntax highlighting (skip re-highlighting on cursor-only moves)
392
+ cmd_text = @history[0].to_s
393
+ if cmd_text != @_hl_text
394
+ @_hl_text = cmd_text.dup
395
+ @_hl_result = cmd_check(@history[0])
396
+ end
399
397
 
400
- # Print history suggestion if available
401
- @ci = @history[1..].find_index {|e| e =~ /^#{Regexp.escape(@history[0].to_s)}./}
398
+ # History suggestion lookup
399
+ @ci = @history[1..].find_index {|e| e =~ /^#{Regexp.escape(cmd_text)}./}
402
400
  unless @ci == nil
403
401
  @ci += 1
404
- @ciprompt = @history[@ci][@history[0].to_s.length..].to_s
405
- end
406
- if @history[0].to_s.length > 1 and @ci
407
- print @ciprompt.c(@c_stamp)
408
- right = true
402
+ @ciprompt = @history[@ci][cmd_text.length..].to_s
409
403
  end
404
+ right = cmd_text.length > 1 && @ci
410
405
 
411
- # Detect if terminal scrolled due to wrapping near the bottom
412
- end_row, _ = @c.pos
413
- printed_len = @pos0 + @history[0].to_s.length
414
- printed_len += @ciprompt.to_s.length if right # Include suggestion text
406
+ # Compute scroll adjustment before drawing (avoids terminal round-trip)
407
+ printed_len = @pos0 + cmd_text.length
408
+ printed_len += @ciprompt.to_s.length if right
415
409
  expected_rows = printed_len > 0 ? (printed_len - 1) / @maxcol : 0
416
- actual_start = end_row - expected_rows
417
- if actual_start < @cmd_row
418
- @cmd_row = [actual_start, 1].max # Terminal scrolled; adjust (min row 1)
410
+ if @cmd_row + expected_rows > @maxrow
411
+ @cmd_row = [@maxrow - expected_rows, 1].max
419
412
  end
420
413
 
414
+ # Redraw prompt + command
415
+ @c.row(@cmd_row)
416
+ @c.col(1)
417
+ @c.clear_screen_down
418
+ print @prompt_last_line
419
+ print @_hl_result
420
+ print @ciprompt.c(@c_stamp) if right
421
+
421
422
  # Position cursor with wrapping math
422
- total_pos = @pos0 + @pos # 0-indexed total position
423
+ total_pos = @pos0 + @pos
423
424
  cursor_row = @cmd_row + total_pos / @maxcol
424
425
  cursor_col = total_pos % @maxcol + 1
425
426
  @c.row(cursor_row)
@@ -1521,7 +1522,10 @@ def rshrc # Write user configuration to .rshrc (portable between machines)
1521
1522
  if conf =~ /@nick\s*=\s*(\{.*?\})/m
1522
1523
  begin
1523
1524
  file_nicks = eval($1)
1524
- @nick = file_nicks.merge(@nick) if file_nicks.is_a?(Hash)
1525
+ if file_nicks.is_a?(Hash)
1526
+ file_nicks.reject! { |k, _| @deleted_nicks&.include?(k) }
1527
+ @nick = file_nicks.merge(@nick)
1528
+ end
1525
1529
  rescue SyntaxError, StandardError
1526
1530
  # If eval fails, keep current @nick
1527
1531
  end
@@ -1818,8 +1822,9 @@ def nick(nick_str = nil) # Define a new nick like this: `:nick "ls = ls --color
1818
1822
  puts "Imported #{imported.length} nicks"
1819
1823
  rshrc
1820
1824
  elsif nick_str.match(/^\s*-/)
1821
- source = nick_str.sub(/^\s*-/, '')
1825
+ source = nick_str.sub(/^\s*-/, '').strip
1822
1826
  if @nick.delete(source)
1827
+ (@deleted_nicks ||= []) << source
1823
1828
  puts "Nick '#{source}' deleted"
1824
1829
  rshrc
1825
1830
  else
@@ -3813,9 +3818,9 @@ loop do
3813
3818
  used_param_nick = first_cmd && @nick[first_cmd] && @nick[first_cmd].include?('{{')
3814
3819
 
3815
3820
  # Do nick/gnick substitution
3816
- ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b/}
3821
+ ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b(?!-)/}
3817
3822
  @cmd = @cmd.gsub(Regexp.union(ca.keys), @nick)
3818
- ga = @gnick.transform_keys {|k| /\b(?<!-)#{Regexp.escape k}\b/}
3823
+ ga = @gnick.transform_keys {|k| /\b(?<!-)#{Regexp.escape k}\b(?!-)/}
3819
3824
  @cmd = @cmd.gsub(Regexp.union(ga.keys), @gnick)
3820
3825
 
3821
3826
  # Expand placeholders if parametrized nick was used
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.16
4
+ version: 3.6.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-21 00:00:00.000000000 Z
11
+ date: 2026-03-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
14
  history, syntax highlighting, theming, auto-cd, auto-opening files and more. UPDATE
15
- v3.6.16: Security hardening, fix shell injection in xclip/editor/mailcap calls,
16
- narrow bare rescues.'
15
+ v3.6.18: Fix nick deletion persistence and hyphenated command substitution.'
17
16
  email: g@isene.com
18
17
  executables:
19
18
  - rsh