| 1 | #!/bin/sh |
| 2 | TEST_PREFIX="[fc]" |
| 3 | . "$(cd "$(dirname "$0")/.." && pwd)/test_harness.sh" |
| 4 | |
| 5 | section "1. fc listing" |
| 6 | check_exit "fc -l lists history" 'fc -l' "0" |
| 7 | check_exit "fc -l -n suppresses line numbers" 'fc -l -n' "0" |
| 8 | check_exit "fc -l -r reverses order" 'fc -l -r' "0" |
| 9 | skip "fc -l produces output" "requires interactive mode (no history in -c)" |
| 10 | |
| 11 | section "2. fc with range" |
| 12 | check_exit "fc -l with negative offset" 'fc -l -5 2>/dev/null; true' "0" |
| 13 | check_exit "fc -l first last range" 'fc -l 1 5 2>/dev/null; true' "0" |
| 14 | check_exit "fc -l with prefix search" 'echo hello; fc -l echo 2>/dev/null; true' "0" |
| 15 | |
| 16 | section "3. fc flags combined" |
| 17 | check_exit "fc -l -n combined" 'fc -l -n 2>/dev/null; true' "0" |
| 18 | check_exit "fc -l -r -n all combined" 'fc -l -r -n 2>/dev/null; true' "0" |
| 19 | |
| 20 | section "4. fc substitution" |
| 21 | compare_output "fc -s re-executes" 'echo testcmd123; fc -s echo 2>/dev/null || true' |
| 22 | check_exit "fc -s with no history" 'fc -s nonexistent_xyz 2>/dev/null; true' "0" |
| 23 | |
| 24 | section "5. fc editor" |
| 25 | check_exit "fc -e with EDITOR" 'FCEDIT=/bin/true; fc -e /bin/true 2>/dev/null; true' "0" |
| 26 | |
| 27 | print_summary |