1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
fn test_EDIT_001_readline_configuration() {
// DOCUMENTATION: Readline configuration (interactive only)
//
// Readline configured via ~/.inputrc:
// # ~/.inputrc
// set editing-mode vi
// set bell-style none
// set completion-ignore-case on
// set show-all-if-ambiguous on
//
// Common settings:
// - editing-mode: emacs or vi
// - bell-style: none, visible, or audible
// - completion-ignore-case: on or off
// - show-all-if-ambiguous: on or off
// - colored-stats: on or off
//
// Configuration is interactive-only, NOT SUPPORTED in scripts.
let script_no_inputrc = r#"
#!/bin/sh
# Scripts don't use readline configuration
printf '%s\n' "No ~/.inputrc needed"
printf '%s\n' "Scripts run without readline"
"#;
let result = BashParser::new(script_no_inputrc);
if let Ok(mut parser) = result {
let parse_result = parser.parse();
assert!(
parse_result.is_ok() || parse_result.is_err(),
"Scripts don't use ~/.inputrc configuration"
);
}
// ~/.inputrc settings (all interactive):
// - Key bindings customization
// - Completion behavior
// - Visual/audio feedback
// - Editing mode preferences
//
// None apply to scripts (no readline library loaded).
}
#[test]
fn test_EDIT_001_interactive_vs_script_input_model() {
// DOCUMENTATION: Interactive vs script input models
//
// Interactive input model (with readline):
// - User types commands character by character
// - Readline processes each keystroke
// - User can edit before pressing Enter
// - Command executed after Enter
// - History saved for recall
// - Completion assists user
//
// Script input model (no readline):
// - Commands predefined in script file
// - No character-by-character processing
// - No editing (commands already written)
// - Commands execute immediately
// - No history (deterministic execution)
// - No completion needed (full commands)
let script_input_model = r#"
#!/bin/sh
# Script input model (no readline)
# Commands predefined (no typing)
command1() {
printf '%s\n' "Command 1"
}
command2() {
printf '%s\n' "Command 2"
}
# Execute directly (no editing)
command1
command2
"#;
let result = BashParser::new(script_input_model);
if let Ok(mut parser) = result {
let parse_result = parser.parse();
assert!(
parse_result.is_ok() || parse_result.is_err(),
"Scripts use predefined commands without readline"
);
}
// Summary:
// Interactive: User types → Readline edits → Shell executes
// Script: Shell reads file → Shell executes (no readline)
//
// bashrs: Scripts only, no readline library needed
}
// ============================================================================
// HISTORY-001: History Expansion (Interactive History, NOT SUPPORTED)
// ============================================================================
//
// Task: HISTORY-001 - Document history expansion
// Status: DOCUMENTED (NOT SUPPORTED - interactive history, non-deterministic)
// Priority: LOW (history expansion not needed in scripts)
//
// History expansion allows referencing previous commands interactively using
// ! (bang) notation. It's interactive-only and non-deterministic.
//
// Bash behavior:
// - !! repeats last command
// - !$ uses last argument from previous command
// - !^ uses first argument from previous command
// - !:n uses nth argument from previous command
// - !string repeats last command starting with 'string'
// - Interactive shells only (requires command history)
//
// bashrs policy:
// - NOT SUPPORTED (interactive history, non-deterministic)
// - Scripts don't have interactive history
// - History expansion removed during purification
// - Non-deterministic (depends on previous commands)
// - POSIX sh supports history expansion, but bashrs doesn't use it
//
// Transformation:
// Bash input:
// echo hello
// !! # Repeats: echo hello
// echo world
// echo !$ # Uses: world
//
// Purified POSIX sh:
// echo hello
// # !! removed (non-deterministic)
// echo world
// # !$ removed (non-deterministic)
//
// Related features:
// - history command - View/manage history (interactive)
// - HISTFILE - History file location
// - HISTSIZE - History size limit
// - fc command - Fix/repeat commands