mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-07-03 18:21:16 -03:00
string shorten: Don't produce output with --quiet
This would've printed stuff in case it didn't have to shorten (which means it "failed" because the logic is "did something"). Fixes #12732
This commit is contained in:
@@ -166,8 +166,11 @@ fn handle(
|
||||
|
||||
pos += skip_escapes(&line, pos).max(1);
|
||||
}
|
||||
if self.quiet && pos != 0 {
|
||||
return Ok(());
|
||||
if self.quiet {
|
||||
if pos != 0 {
|
||||
return Ok(());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let output = match pos {
|
||||
@@ -215,8 +218,11 @@ fn handle(
|
||||
}
|
||||
}
|
||||
|
||||
if self.quiet && pos != line.len() {
|
||||
return Ok(());
|
||||
if self.quiet {
|
||||
if pos != line.len() {
|
||||
return Ok(());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if pos == line.len() {
|
||||
|
||||
@@ -1064,6 +1064,14 @@ string shorten -m 2 foo
|
||||
string shorten -m 5 foobar
|
||||
# CHECK: foob…
|
||||
|
||||
# Should produce no output and return false because there was nothing to shorten.
|
||||
string shorten -m 2 -q 12
|
||||
echo $status
|
||||
# CHECK: 1
|
||||
string shorten -lm 2 -q 12
|
||||
echo $status
|
||||
# CHECK: 1
|
||||
|
||||
# Char is longer than width, we truncate instead.
|
||||
string shorten -m 5 --char ........ foobar
|
||||
# CHECK: fooba
|
||||
|
||||
Reference in New Issue
Block a user