Run fish_indent on all our fish scripts

It's now good enough to do so.

We don't allow grid-alignment:

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z              -a '(something)'
```

becomes

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z -a '(something)'
```

It's just more trouble than it is worth.

The one part I'd change:

We align and/or'd parts of an if-condition with the in-block code:

```fish
if true
   and false
    dosomething
end
```

becomes

```fish
if true
    and false
    dosomething
end
```

but it's not used terribly much and if we ever fix it we can just
reindent.
This commit is contained in:
Fabian Homborg 2020-01-13 20:34:22 +01:00
parent 31e6ae0099
commit 69b464bc37
36 changed files with 1322 additions and 1233 deletions

View File

@ -3,7 +3,9 @@
function __fish_keybase_line_ends_with
set -l line (commandline -poc | string match -v -r '^-')
for i in (seq -1 -1 -(count $argv))
if test "$line[$i]" != "$argv[$i]"; return 1; end
if test "$line[$i]" != "$argv[$i]"
return 1
end
end
end

View File

@ -12,7 +12,8 @@ if test (uname) = Darwin
# macOS 15 is Darwin 19, this is an issue at least up to 10.15.3.
# If this is fixed in later versions uncomment the second check.
if test "$darwin_version[1]" = 19 # -a "$darwin_version[2]" -le 3
function __fish_describe_command; end
function __fish_describe_command
end
# (remember: exit when `source`ing only exits the file, not the shell)
exit
end

View File

@ -194,7 +194,8 @@ function help --description 'Show help for the fish shell'
case '*'
printf (_ 'help: Help is being displayed in %s.\n') $fish_browser[1]
end
$fish_browser $page_url &; disown
$fish_browser $page_url &
disown
else
# Work around lynx bug where <div class="contents"> always has the same formatting as links (unreadable)
# by using a custom style sheet. See https://github.com/fish-shell/fish-shell/issues/4170

View File

@ -3,9 +3,12 @@
echo first && echo second
echo third || echo fourth
true && false ; echo "true && false: $status"
true || false ; echo "true || false: $status"
true && false || true ; echo "true && false || true: $status"
true && false
echo "true && false: $status"
true || false
echo "true || false: $status"
true && false || true
echo "true && false || true: $status"
# CHECK: first
# CHECK: second
# CHECK: third
@ -15,10 +18,19 @@ true && false || true ; echo "true && false || true: $status"
# "&& and || in if statements"
if true || false ; echo "if test 1 ok" ; end
if true && false ; else; echo "if test 2 ok" ; end
if true && false ; or true ; echo "if test 3 ok" ; end
if [ 0 = 1 ] || [ 5 -ge 3 ] ; echo "if test 4 ok"; end
if true || false
echo "if test 1 ok"
end
if true && false
else
echo "if test 2 ok"
end
if true && false; or true
echo "if test 3 ok"
end
if [ 0 = 1 ] || [ 5 -ge 3 ]
echo "if test 4 ok"
end
# CHECK: if test 1 ok
# CHECK: if test 2 ok
# CHECK: if test 3 ok
@ -46,11 +58,16 @@ end
# "Nots"
true && ! false ; echo $status
not true && ! false ; echo $status
not not not true ; echo $status
not ! ! not true ; echo $status
not ! echo not ! ; echo $status
true && ! false
echo $status
not true && ! false
echo $status
not not not true
echo $status
not ! ! not true
echo $status
not ! echo not !
echo $status
# CHECK: 0
# CHECK: 1
# CHECK: 1
@ -60,7 +77,12 @@ not ! echo not ! ; echo $status
# "Complex scenarios"
begin; echo 1 ; false ; end || begin ; echo 2 && echo 3 ; end
begin
echo 1
false
end || begin
echo 2 && echo 3
end
if false && true
or not false

View File

@ -1,5 +1,7 @@
# RUN: %fish %s
function complete_test_alpha1; echo $argv; end
function complete_test_alpha1
echo $argv
end
complete -c complete_test_alpha1 --no-files -a '(commandline)'
complete -c complete_test_alpha2 --no-files -w 'complete_test_alpha1 extra1'
@ -29,7 +31,9 @@ complete -C'myalias2 call3 '
# Ensure that commands can't wrap themselves - if this did,
# the completion would be executed a bunch of times.
function t --wraps t; echo t; end
function t --wraps t
echo t
end
complete -c t -fa '(t)'
complete -C't '
# CHECK: t

View File

@ -1,5 +1,7 @@
#RUN: %fish %s
begin; end > . ; status -b; and echo "status -b returned true after bad redirect on a begin block"
begin
end >.
status -b; and echo "status -b returned true after bad redirect on a begin block"
# Note that we sometimes get fancy quotation marks here, so let's match three characters
#CHECKERR: <W> fish: An error occurred while redirecting file {{...}}
#CHECKERR: {{open: Is a directory|open: Invalid argument}}

View File

@ -6,13 +6,23 @@ function empty
end
# functions should not preserve $status
false; empty; echo $status
false
empty
echo $status
# CHECK: 0
true; empty; echo $status
true
empty
echo $status
# CHECK: 0
# blocks should preserve $status
false; begin; end; echo $status
false
begin
end
echo $status
# CHECK: 1
true; begin; end; echo $status
true
begin
end
echo $status
# CHECK: 0

View File

@ -8,18 +8,26 @@ echo $previously_undefined
eval "echo you can\\'t see this 1>&2" 2>/dev/null
# Test return statuses
false; eval true; echo $status
false
eval true
echo $status
# CHECK: 0
false; eval false; echo $status
false
eval false
echo $status
# CHECK: 1
# Test return status in case of parsing error
false; eval "("; echo $status
false
eval "("
echo $status
# CHECK: 1
# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): Unexpected end of string, expecting ')'
# CHECKERR: (
# CHECKERR: ^
false; eval '""'; echo $status
false
eval '""'
echo $status
# CHECK: 1
# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): The expanded command was empty.
# CHECKERR: ""
@ -29,18 +37,22 @@ function empty
end
# Regression tests for issue #5692
false; eval;
false
eval
echo blank eval: $status # 0
# CHECK: blank eval: 0
false; eval "";
false
eval ""
echo empty arg eval: $status # 0
# CHECK: empty arg eval: 0
false; eval empty;
false
eval empty
echo empty function eval $status # 0
# CHECK: empty function eval 0
false; eval "begin; end;";
false
eval "begin; end;"
echo empty block eval: $status # 0
# CHECK: empty block eval: 0

View File

@ -1,5 +1,7 @@
# RUN: %fish %s
argparse r-require= -- --require 2>/dev/null ; echo $status
argparse r-require= -- --require 2>/dev/null
echo $status
# CHECK: 2
argparse r-require= -- --require 2>&- ; echo $status
argparse r-require= -- --require 2>&-
echo $status
# CHECK: 2

View File

@ -34,11 +34,15 @@ math -- '-4 * 2'
# CHECK: -8
# Validate some rounding functions
math 'round(3/2)' ; math 'floor(3/2)' ; math 'ceil(3/2)'
math 'round(3/2)'
math 'floor(3/2)'
math 'ceil(3/2)'
# CHECK: 2
# CHECK: 1
# CHECK: 2
math 'round(-3/2)' ; math 'floor(-3/2)' ; math 'ceil(-3/2)'
math 'round(-3/2)'
math 'floor(-3/2)'
math 'ceil(-3/2)'
# CHECK: -2
# CHECK: -2
# CHECK: -1

View File

@ -7,7 +7,9 @@ function save_pgroup -a var_name
end
# Here everything should live in the pgroup of the first fish_test_helper.
$fth print_pgrp | read -g global_group | save_pgroup g1 | begin; save_pgroup g2; end
$fth print_pgrp | read -g global_group | save_pgroup g1 | begin
save_pgroup g2
end
[ "$global_group" -eq "$g1" ] && [ "$g1" -eq "$g2" ]
and echo "All pgroups agreed"
@ -18,9 +20,14 @@ or echo "Pgroups disagreed. Should be in $global_group but found $g1 and $g2"
# Unfortunately we don't know what fish's pgroup is (it may not be fish's pid).
# So run it twice and verify that everything agrees; this implies that it could
# not have used any of the pids of the child procs.
function nothing ; end
nothing | $fth print_pgrp | read -g a0 | save_pgroup a1 | begin; save_pgroup a2; end
nothing | $fth print_pgrp | read -g b0 | save_pgroup b1 | begin; save_pgroup b2; end
function nothing
end
nothing | $fth print_pgrp | read -g a0 | save_pgroup a1 | begin
save_pgroup a2
end
nothing | $fth print_pgrp | read -g b0 | save_pgroup b1 | begin
save_pgroup b2
end
[ "$a0" -eq "$a1" ] && [ "$a1" -eq "$a2" ] \
&& [ "$b0" -eq "$b1" ] && [ "$b1" -eq "$b2" ] \

View File

@ -13,10 +13,12 @@ set -l
# CHECK: b
# CHECK: c
echo "a b b" | read a b; string escape $a $b
echo "a b b" | read a b
string escape $a $b
# CHECK: a
# CHECK: 'b b'
echo 'a<><>b<>b' | read -d '<>' a b; printf %s\n $a $b
echo 'a<><>b<>b' | read -d '<>' a b
printf %s\n $a $b
# CHECK: a
# CHECK: <>b<>b

View File

@ -449,7 +449,9 @@ echo "global-vs-universal 5: $__fish_test_global_vs_universal"
# CHECK: global-vs-universal 5:
# Export local variables from all parent scopes (issue #6153).
function func; echo $local; end
function func
echo $local
end
set -lx local outer
func
# CHECK: outer
@ -458,12 +460,16 @@ begin
# CHECK: outer
set -lx local inner
begin; func; end
begin
func
end
# CHECK: inner
end
# Skip importing universal variables (#5258)
while set -q EDITOR; set -e EDITOR; end
while set -q EDITOR
set -e EDITOR
end
set -Ux EDITOR emacs -nw
# CHECK: $EDITOR: not set in global scope
# CHECK: $EDITOR: set in universal scope, exported, with 2 elements

View File

@ -4,7 +4,8 @@
echo About to sigint
$helper sigint_parent &
while true ; end
while true
end
echo I should not be printed because I got sigint
#CHECK: About to sigint

View File

@ -1,15 +1,19 @@
# RUN: %fish -C 'set -l fish %fish' %s
$fish -c 'function main; exit 4; true; end; main'; echo $status
$fish -c 'function main; exit 4; true; end; main'
echo $status
#CHECK: 4
$fish -c 'begin; exit 5; true; end'; echo $status
$fish -c 'begin; exit 5; true; end'
echo $status
#CHECK: 5
$fish -c 'kill -SIGHUP %self'; echo $status
$fish -c 'kill -SIGHUP %self'
echo $status
#CHECK: 129
$fish -c 'function main; kill -SIGTERM %self; true; end; main'; echo $status
$fish -c 'function main; kill -SIGTERM %self; true; end; main'
echo $status
#CHECK: 143
function alarm --on-signal ALRM

View File

@ -296,10 +296,12 @@ string repeat -n0; or echo "exit 1"
string repeat -m0; or echo "exit 1"
# CHECK: exit 1
string repeat -n1 -N "there is "; echo "no newline"
string repeat -n1 -N "there is "
echo "no newline"
# CHECK: there is no newline
string repeat -n1 --no-newline "there is "; echo "no newline"
string repeat -n1 --no-newline "there is "
echo "no newline"
# CHECK: there is no newline
string repeat -n10 -m4 "foo"

View File

@ -58,13 +58,20 @@ xPATH={/usr,}/bin sh -c 'echo $xPATH'
yPATH=/usr/bin:/bin count $yPATH
# CHECK: b
a=b begin; true | echo $a; end
a=b begin
true | echo $a
end
# CHECK: b
a=b if true; echo $a; end
a=b if true
echo $a
end
# CHECK: b
a=b switch x; case x; echo $a; end
a=b switch x
case x
echo $a
end
complete -c x --erase
complete -c x -xa arg