record: Nummern unter 1 und Text sind ein Fehler statt Zeilen vom Ende

This commit is contained in:
wkh
2026-10-11 22:48:42 +02:00
parent f83d1bd6f8
commit d5286c3600
3 changed files with 19 additions and 0 deletions
+2
View File
@@ -72,6 +72,8 @@ end
Rdb.register('record', 'Find and output a record from a table', 'record number < table') do |args|
die 'usage: record number < table' unless args.size == 1
die "'#{args[0]}' is not a record number (1, 2, 3 ...)" unless args[0].match?(/\A\d+\z/) && args[0].to_i.positive?
t = table_in
row = t.rows[args[0].to_i - 1]
t.with(rows: row ? [row] : []).write