Skip to content

Commit 53c6d6f

Browse files
committed
Change test version
2 parents 83897c8 + 5867ce1 commit 53c6d6f

38 files changed

+402
-146
lines changed

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Bash tests
2121
run: |
2222
dir=$PWD
23-
git clone https://github.com/shellgei/rusty_bash_test -b v1.2.1 --depth 1
23+
git clone https://github.com/shellgei/rusty_bash_test -b v1.2.2 --depth 1
2424
#git clone https://github.com/shellgei/rusty_bash_test --depth 1
2525
cd rusty_bash_test
2626
./test.bash $dir

.github/workflows/ubuntu.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- name: Bash tests
2121
run: |
2222
dir=$PWD
23-
git clone https://github.com/shellgei/rusty_bash_test -b v1.2.1 --depth 1
24-
#git clone https://github.com/shellgei/rusty_bash_test --depth 1
23+
git clone https://github.com/shellgei/rusty_bash_test -b v1.2.2 --depth 1
2524
cd rusty_bash_test
2625
./test.bash $dir

.sushrc

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,6 @@ alias ll='ls -l'
3030
alias git-writing='git add -A ; git commit -m Writing ; git push'
3131

3232

33-
# completion test
34-
# thanks to: https://blog.cybozu.io/entry/2016/09/26/080000
35-
36-
#_dummy () {
37-
# COMPREPLY=( $(compgen -W "one two" -- "${cur}" ) )
38-
#} && complete -F _dummy hoge
39-
#
40-
#_git_comp () {
41-
# if [ "$COMP_CWORD" = 1 ] ; then
42-
# CANDS=( $( git |& grep '^ *[a-z]' | awk '{print $1}') )
43-
# COMPREPLY=( $(compgen -W "${CANDS[@]}" -- "${cur}") )
44-
# elif [ "$COMP_CWORD" = 2 -a "$prev" = switch ] ; then
45-
# COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' )" -- "${cur}" ) )
46-
# elif [ "$COMP_CWORD" = 2 -a "$prev" = merge ] ; then
47-
# COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' )" -- "${cur}" ) )
48-
# elif [ "$COMP_CWORD" = 2 -a "$prev" = diff ] ; then
49-
# COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' ) $(compgen -f)" -- "${cur}" ) )
50-
# fi
51-
#} && complete -F _git_comp git
52-
#
53-
#_colcon_comp () {
54-
# if [ "$COMP_CWORD" = 1 ] ; then
55-
# CANDS=( $( colcon |& sed -n 2p | tr , \\n | tr -d '{} ' ) )
56-
# COMPREPLY=( $(compgen -W "${CANDS[@]}" -- "${cur}") )
57-
# fi
58-
#} && complete -F _colcon_comp colcon
59-
60-
6133
command_not_found_handle() { #command_not_found should be loaded before bash-completion in this stage
6234
if [ -e /usr/lib/command-not-found ] ; then
6335
/usr/lib/command-not-found -- "$1"
@@ -78,6 +50,3 @@ elif [ -f /etc/bash_completion ]; then
7850
. /etc/bash_completion
7951
complete -d cd
8052
fi
81-
82-
83-

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "sush"
3-
version = "1.2.1"
3+
version = "1.2.2"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
99
nix = { version = "0.29.0", features = ["fs", "process", "signal", "term", "user", "time", "hostname", "resource"]}
10-
termion = "4.0.3"
10+
termion = "4.0.5"
1111
unicode-width = "0.1.11"
1212
signal-hook = "0.3.17"
1313
rev_lines = "0.3.0"

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ueda@uedaP1g6:main🌵~/GIT/rusty_bash🍣
4242

4343
## Comparison with Bash 5.2
4444

45-
This graph shows the test result with the script in `./sush_test/bash_genuine_test` of [this test repository](https://github.com/ryuichiueda/bash_for_sush_test). Currently, the binary built from alpha repo has passed 24 of 84 test scripts.
45+
This graph shows the test result with the script in `./sush_test/bash_genuine_test` of [this test repository](https://github.com/ryuichiueda/bash_for_sush_test). Currently, the binary built from alpha repo has passed 27 of 84 test scripts.
4646

4747
![](https://github.com/ryuichiueda/bash_for_sush_test/blob/master/sush_test/graph.png)
4848

@@ -77,6 +77,9 @@ The following behavior of Bash will not be imitated by `sush`. So we alter the r
7777
🍣 (( 1++ ))
7878
sush: ((: 1++ : syntax error: operand expected (error token is "+")
7979
```
80+
* error messages of `readonly`
81+
* We added `readonly: ` to the messages in `attr.right`.
82+
* e.g.: `./attr.tests: line 17: a: readonly variable` -> `./attr.tests: line 17: readonly: a: readonly variable`
8083
8184
## Contribution
8285

error

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,39 @@
6363
./test_fixed.bash
6464
./test_fixed.bash
6565
./test_fixed.bash
66+
./test_fixed.bash
67+
./test_fixed.bash
68+
./test_fixed.bash
69+
./test_fixed.bash
70+
./test_fixed.bash
71+
./test_job.bash
72+
./test_job.bash
73+
./test_fixed.bash
74+
./test_fixed.bash
75+
./test_fixed.bash
76+
./test_fixed.bash
77+
./test_fixed.bash
78+
./test_fixed.bash
79+
./test_fixed.bash
80+
./test_fixed.bash
81+
./test_fixed.bash
82+
./test_fixed.bash
83+
./test_fixed.bash
84+
./test_fixed.bash
85+
./test_fixed.bash
86+
./test_fixed.bash
87+
./test_fixed.bash
88+
./test_fixed.bash
89+
./test_fixed.bash
90+
./test_fixed.bash
91+
./test_fixed.bash
92+
./test_fixed.bash
93+
./test_fixed.bash
94+
./test_fixed.bash
95+
./test_fixed.bash
96+
./test_fixed.bash
97+
./test_fixed.bash
98+
./test_fixed.bash
99+
./test_fixed.bash
100+
./test_fixed.bash
101+
./test_fixed.bash

src/core/builtins/alias.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
use crate::ShellCore;
55

66
pub fn alias(core: &mut ShellCore, args: &[String]) -> i32 {
7-
if args.len() == 1 {
7+
if args.len() == 1
8+
|| args.len() == 2 && args[1] == "-p" {
9+
if ! core.shopts.query("expand_aliases") {
10+
return 0;
11+
}
812
for k in &core.db.get_indexes_all("BASH_ALIASES") {
913
let v = core.db.get_elem("BASH_ALIASES", k).unwrap();
1014
println!("alias {k}='{v}'");
@@ -14,10 +18,17 @@ pub fn alias(core: &mut ShellCore, args: &[String]) -> i32 {
1418

1519
if args.len() == 2 && args[1].contains("=") {
1620
let kv: Vec<String> = args[1].split('=').map(|t| t.to_string()).collect();
17-
//core.aliases.insert(kv[0].clone(), kv[1..].join("="));
1821
let _ = core
1922
.db
2023
.set_assoc_elem("BASH_ALIASES", &kv[0], &kv[1..].join("="), None);
24+
return 0;
25+
}
26+
27+
if args.len() == 2
28+
&& core.db.has_array_value("BASH_ALIASES", &args[1]) {
29+
let alias = core.db.get_elem("BASH_ALIASES", &args[1]).unwrap();
30+
println!("alias {}='{}'", &args[1], &alias);
31+
return 0;
2132
}
2233

2334
0

src/core/builtins/command.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::elements::command::simple::SimpleCommand;
55
use crate::elements::io::pipe::Pipe;
66
use crate::utils::{arg, file};
7-
use crate::{error, proc_ctrl, ShellCore};
7+
use crate::{error, file_check, proc_ctrl, ShellCore, utils};
88

99
pub fn builtin(core: &mut ShellCore, args: &[String]) -> i32 {
1010
if args.len() <= 1 {
@@ -27,7 +27,14 @@ fn command_v(words: &[String], core: &mut ShellCore, large_v: bool) -> i32 {
2727
let mut return_value = 1;
2828

2929
for com in words.iter() {
30-
if core.db.has_array_value("BASH_ALIASES", com) {
30+
if utils::reserved(com) {
31+
return_value = 0;
32+
match large_v {
33+
true => println!("{} is a shell keyword", &com),
34+
false => println!("{}", &com),
35+
}
36+
} else if core.db.has_array_value("BASH_ALIASES", com) {
37+
return_value = 0;
3138
let alias = core.db.get_elem("BASH_ALIASES", com).unwrap();
3239
match large_v {
3340
true => println!("{} is aliased to `{}'", &com, &alias),
@@ -40,12 +47,27 @@ fn command_v(words: &[String], core: &mut ShellCore, large_v: bool) -> i32 {
4047
true => println!("{} is a shell builtin", &com),
4148
false => println!("{}", &com),
4249
}
50+
} else if core.db.functions.contains_key(com) {
51+
return_value = 0;
52+
match large_v {
53+
true => {
54+
println!("{} is a function", &com);
55+
core.db.functions.get_mut(com).unwrap().pretty_print(0);
56+
},
57+
false => println!("{}", &com),
58+
}
4359
} else if let Some(path) = file::search_command(com) {
4460
return_value = 0;
4561
match large_v {
4662
true => println!("{} is {}", &com, &path),
4763
false => println!("{}", &com),
4864
}
65+
} else if file_check::is_executable(com) {
66+
return_value = 0;
67+
match large_v {
68+
true => println!("{} is {}", &com, &com),
69+
false => println!("{}", &com),
70+
}
4971
} else if large_v {
5072
let msg = format!("command: {com}: not found");
5173
error::print(&msg, core);

src/core/builtins/loop_control.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ pub fn continue_(core: &mut ShellCore, args: &[String]) -> i32 {
5757
return 0;
5858
}
5959

60-
core.continue_counter += 1;
60+
//core.continue_counter += 1;
61+
core.continue_counter = 1;
6162
if args.len() < 2 {
6263
return 0;
6364
}
6465

6566
match args[1].parse::<i32>() {
6667
Ok(n) => {
6768
if n > 0 {
68-
core.continue_counter += n - 1;
69+
//core.continue_counter += n - 1;
70+
core.continue_counter = n;
6971
} else {
7072
eprintln!("sush: continue: {}: loop count out of range", args[1]);
7173
return 1;

src/core/builtins/option.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ pub fn set(core: &mut ShellCore, args: &[String]) -> i32 {
115115
if args[1].starts_with("--") {
116116
args[1] = core.db.position_parameters[0][0].clone();
117117
args.remove(0);
118-
dbg!("{:?}", &args);
119118
match set_positions(core, &args) {
120119
Ok(()) => return 0,
121120
Err(e) => {
@@ -152,6 +151,8 @@ pub fn set(core: &mut ShellCore, args: &[String]) -> i32 {
152151
if let Err(e) = set_positions(core, &args) {
153152
e.print(core);
154153
return 2;
154+
}else{
155+
return 0;
155156
}
156157
}
157158

0 commit comments

Comments
 (0)