remove some uses of $IFS

This is a step towards resolving issue #4156. It replaces uses of `$IFS`
with other solutions.
This commit is contained in:
Kurtis Rader 2017-07-24 20:45:43 -07:00
parent 6f46f6b45a
commit 8e87d595b7
9 changed files with 187 additions and 228 deletions

View file

@ -3,17 +3,12 @@ complete -c dd -d 'display help and exit' -xa '--help'
complete -c dd -d 'output version information and exit' -xa '--version' complete -c dd -d 'output version information and exit' -xa '--version'
function __fish_complete_dd --description 'Complete dd operands' function __fish_complete_dd --description 'Complete dd operands'
# set operand_string as a local variable containing the current command-line token. # set operand_string as a local variable containing the current command-line token.
set -l operand_string (commandline -t) set -l operand_string (commandline -t)
switch $operand_string switch $operand_string
case 'if=*' 'of=*' case 'if=*' 'of=*'
# the read command uses $IFS to tokenise stdin input string replace = ' ' -- $operand_string | read -l operand value
set -l IFS =
# $operand now contains the left side of the operator, $value the right
echo $operand_string | read -l operand value
for entry in $value* for entry in $value*
# if $entry is a directory, append a '/' # if $entry is a directory, append a '/'
@ -25,78 +20,61 @@ function __fish_complete_dd --description 'Complete dd operands'
end end
case 'iflag=*' 'oflag=*' case 'iflag=*' 'oflag=*'
set -l IFS = string replace = ' ' -- $operand_string | read -l operand complete
echo $operand_string | read -l operand value string match -q '*,' -- $complete
or set complete ''
set -l IFS ' ' printf "%s\t%s\n" "$operand=$complete""append" "append mode (makes sense only for output; conv=notrunc suggested)"
echo $value | sed -e 's/\(.*\)\(,\)/\1 \2/' | read -l complete comma printf "%s\t%s\n" "$operand=$complete""direct" "use direct I/O for data"
printf "%s\t%s\n" "$operand=$complete""directory" "fail unless a directory"
# check if there is only one option printf "%s\t%s\n" "$operand=$complete""dsync" "use synchronized I/O for data"
if test $comma = '' printf "%s\t%s\n" "$operand=$complete""sync" "use synchronized I/O for data and metadata"
set complete '' printf "%s\t%s\n" "$operand=$complete""fullblock" "accumulate full blocks of input (iflag only)"
else printf "%s\t%s\n" "$operand=$complete""nonblock" "use non-blocking I/O"
set complete $complete, printf "%s\t%s\n" "$operand=$complete""noatime" "do not update access time"
end printf "%s\t%s\n" "$operand=$complete""nocache" "discard cached data"
printf "%s\t%s\n" "$operand=$complete""noctty" "do not assign controlling terminal from file"
printf "%s\t%s\n" "$operand=$complete""append" "append mode (makes sense only for output; conv=notrunc suggested)" printf "%s\t%s\n" "$operand=$complete""nofollow" "do not follow symbolic links"
printf "%s\t%s\n" "$operand=$complete""direct" "use direct I/O for data"
printf "%s\t%s\n" "$operand=$complete""directory" "fail unless a directory"
printf "%s\t%s\n" "$operand=$complete""dsync" "use synchronized I/O for data"
printf "%s\t%s\n" "$operand=$complete""sync" "use synchronized I/O for data and metadata"
printf "%s\t%s\n" "$operand=$complete""fullblock" "accumulate full blocks of input (iflag only)"
printf "%s\t%s\n" "$operand=$complete""nonblock" "use non-blocking I/O"
printf "%s\t%s\n" "$operand=$complete""noatime" "do not update access time"
printf "%s\t%s\n" "$operand=$complete""nocache" "discard cached data"
printf "%s\t%s\n" "$operand=$complete""noctty" "do not assign controlling terminal from file"
printf "%s\t%s\n" "$operand=$complete""nofollow" "do not follow symbolic links"
case 'conv=*' case 'conv=*'
set -l IFS = string replace = ' ' -- $operand_string | read -l operand complete
echo $operand_string | read -l operand value string match -q '*,' -- $complete
or set complete ''
set -l IFS ' ' printf "%s\t%s\n" "$operand=$complete""ascii" "from EBCDIC to ASCII"
echo $value | sed -e 's/\(.*\)\(,\)/\1 \2/' | read -l complete comma printf "%s\t%s\n" "$operand=$complete""ebcdic" "from ASCII to EBCDIC"
printf "%s\t%s\n" "$operand=$complete""ibm" "from ASCII to alternate EBCDIC"
if test $comma = '' printf "%s\t%s\n" "$operand=$complete""block" "pad newline-terminated records with spaces to cbs-size"
set complete '' printf "%s\t%s\n" "$operand=$complete""unblock" "replace trailing spaces in cbs-size records with newline"
else printf "%s\t%s\n" "$operand=$complete""lcase" "change upper case to lower case"
set complete $complete, printf "%s\t%s\n" "$operand=$complete""ucase" "change lower case to upper case"
end printf "%s\t%s\n" "$operand=$complete""swab" "swap every pair of input bytes"
printf "%s\t%s\n" "$operand=$complete""sync" "pad every input block with NULs to ibs-size; with block or ublock use spaces"
printf "%s\t%s\n" "$operand=$complete""ascii" "from EBCDIC to ASCII" printf "%s\t%s\n" "$operand=$complete""excl" "fail if the output file already exists"
printf "%s\t%s\n" "$operand=$complete""ebcdic" "from ASCII to EBCDIC" printf "%s\t%s\n" "$operand=$complete""nocreat" "do not create the output file"
printf "%s\t%s\n" "$operand=$complete""ibm" "from ASCII to alternate EBCDIC" printf "%s\t%s\n" "$operand=$complete""notrunc" "do not truncate the output file"
printf "%s\t%s\n" "$operand=$complete""block" "pad newline-terminated records with spaces to cbs-size" printf "%s\t%s\n" "$operand=$complete""noerror" "continue after read errors"
printf "%s\t%s\n" "$operand=$complete""unblock" "replace trailing spaces in cbs-size records with newline" printf "%s\t%s\n" "$operand=$complete""fdatasync" "physically write output file data before finishing"
printf "%s\t%s\n" "$operand=$complete""lcase" "change upper case to lower case" printf "%s\t%s\n" "$operand=$complete""fsync" "physically write output file data and metadata before finishing"
printf "%s\t%s\n" "$operand=$complete""ucase" "change lower case to upper case"
printf "%s\t%s\n" "$operand=$complete""swab" "swap every pair of input bytes"
printf "%s\t%s\n" "$operand=$complete""sync" "pad every input block with NULs to ibs-size; with block or ublock use spaces"
printf "%s\t%s\n" "$operand=$complete""excl" "fail if the output file already exists"
printf "%s\t%s\n" "$operand=$complete""nocreat" "do not create the output file"
printf "%s\t%s\n" "$operand=$complete""notrunc" "do not truncate the output file"
printf "%s\t%s\n" "$operand=$complete""noerror" "continue after read errors"
printf "%s\t%s\n" "$operand=$complete""fdatasync" "physically write output file data before finishing"
printf "%s\t%s\n" "$operand=$complete""fsync" "physically write output file data and metadata before finishing"
case 'status=*' case 'status=*'
printf "%s\t%s\n" status=noxfer "suppress final transfer statistics" printf "%s\t%s\n" status=noxfer "suppress final transfer statistics"
printf "%s\t%s\n" status=none "suppress everything but errors" printf "%s\t%s\n" status=none "suppress everything but errors"
printf "%s\t%s\n" status=progress "show periodic transfer statistics" printf "%s\t%s\n" status=progress "show periodic transfer statistics"
case '*' case '*'
printf "%s=\t%s\n" bs "read and write up to BYTES bytes at a time" printf "%s=\t%s\n" bs "read and write up to BYTES bytes at a time"
printf "%s=\t%s\n" cbs "convert BYTES bytes at a time" printf "%s=\t%s\n" cbs "convert BYTES bytes at a time"
printf "%s=\t%s\n" conv "convert the file as per the comma separated symbol list" printf "%s=\t%s\n" conv "convert the file as per the comma separated symbol list"
printf "%s=\t%s\n" count "copy only BLOCKS input blocks" printf "%s=\t%s\n" count "copy only BLOCKS input blocks"
printf "%s=\t%s\n" ibs "read up to BYTES bytes at a time (default 512)" printf "%s=\t%s\n" ibs "read up to BYTES bytes at a time (default 512)"
printf "%s=\t%s\n" if "read from FILE instead of stdin" printf "%s=\t%s\n" if "read from FILE instead of stdin"
printf "%s=\t%s\n" iflag "read as per the comma separated symbol list" printf "%s=\t%s\n" iflag "read as per the comma separated symbol list"
printf "%s=\t%s\n" obs "write BYTES bytes at a time (default 512)" printf "%s=\t%s\n" obs "write BYTES bytes at a time (default 512)"
printf "%s=\t%s\n" of "write to FILE instead of stdout" printf "%s=\t%s\n" of "write to FILE instead of stdout"
printf "%s=\t%s\n" oflag "write as per the comma separated symbol list" printf "%s=\t%s\n" oflag "write as per the comma separated symbol list"
printf "%s=\t%s\n" seek "skip BLOCKS obs-sized blocks at the start of output" printf "%s=\t%s\n" seek "skip BLOCKS obs-sized blocks at the start of output"
printf "%s=\t%s\n" skip "skip BLOCKS ibs-sized blocks at the start of input" printf "%s=\t%s\n" skip "skip BLOCKS ibs-sized blocks at the start of input"
printf "%s=\t%s\n" status "set the level of information to print to stderr" printf "%s=\t%s\n" status "set the level of information to print to stderr"
end end
end end

View file

@ -1,103 +1,99 @@
set -l __fish_iptables_tables filter nat mangle raw security set -l __fish_iptables_tables filter nat mangle raw security
function __fish_iptables_current_table function __fish_iptables_current_table
set -l next_is_table 1 set -l next_is_table 1
for token in (commandline -oc) for token in (commandline -oc)
switch $token switch $token
case "--table=*" case "--table=*"
set -l IFS "=" echo (string split -m1 = -- $token)[2]
echo $token | while read a b return 0
echo $b case "--table"
end set next_is_table 0
return 0 case "-*t*"
case "--table" set next_is_table 0
set next_is_table 0 case "*"
case "-*t*" if [ $next_is_table -eq 0 ]
set next_is_table 0 echo $token
case "*" return 0
if [ $next_is_table -eq 0 ] end
echo $token end
return 0 end
end return 1
end
end
return 1
end end
function __fish_iptables_user_chains function __fish_iptables_user_chains
# There can be user-defined chains so we need iptables' help # There can be user-defined chains so we need iptables' help
set -l tablearg set -l tablearg
set -l table (__fish_iptables_current_table) set -l table (__fish_iptables_current_table)
if __fish_iptables_current_table if __fish_iptables_current_table
set tablearg "--table=$table" set tablearg "--table=$table"
end end
# This only works as root, so ignore errors # This only works as root, so ignore errors
iptables $tablearg -L ^/dev/null | grep Chain | while read a b c iptables $tablearg -L ^/dev/null | grep Chain | while read a b c
echo $b echo $b
end end
end end
function __fish_iptables_chains function __fish_iptables_chains
set -l table (__fish_iptables_current_table) set -l table (__fish_iptables_current_table)
[ -z $table ]; and set -l table "*" [ -z $table ]
set -l prerouting "PREROUTING For packets that are coming in" and set -l table "*"
set -l input "INPUT For packets destined to local sockets" set -l prerouting "PREROUTING For packets that are coming in"
set -l output "OUTPUT For locally-generated packets" set -l input "INPUT For packets destined to local sockets"
set -l forward "FORWARD For packets being routed through" set -l output "OUTPUT For locally-generated packets"
set -l postrouting "POSTROUTING For packets that are about to go out" set -l forward "FORWARD For packets being routed through"
switch $table set -l postrouting "POSTROUTING For packets that are about to go out"
case "filter" switch $table
echo $input case "filter"
echo $forward echo $input
echo $output echo $forward
case "nat" echo $output
echo $prerouting case "nat"
echo $output echo $prerouting
echo $postrouting echo $output
case "mangle" echo $postrouting
echo $prerouting case "mangle"
echo $input echo $prerouting
echo $output echo $input
echo $forward echo $output
echo $postrouting echo $forward
case "raw" echo $postrouting
echo $prerouting case "raw"
echo $output echo $prerouting
case "security" echo $output
echo $input case "security"
echo $output echo $input
echo $forward echo $output
case '*' echo $forward
echo $prerouting case '*'
echo $input echo $prerouting
echo $output echo $input
echo $forward echo $output
echo $postrouting echo $forward
end echo $postrouting
__fish_iptables_user_chains end
__fish_iptables_user_chains
end end
function __fish_iptables_has_chain function __fish_iptables_has_chain
# Remove descriptions # Remove descriptions
set -l IFS " " set -l chains (__fish_iptables_chains | string split -m1 " " | while read a b; echo $a; end)
set -l chains (__fish_iptables_chains | while read a b; echo $a; end) set -l cmdline (commandline -op)
set -e IFS for c in $chains
set -l cmdline (commandline -op) if contains -- $c $cmdline
for c in $chains return 0
if contains -- $c $cmdline end
return 0 end
end return 1
end
return 1
end end
# A target is a user-defined chain, one of "ACCEPT DROP RETURN" or an extension (TODO) # A target is a user-defined chain, one of "ACCEPT DROP RETURN" or an extension (TODO)
function __fish_iptables_targets function __fish_iptables_targets
echo "ACCEPT" echo "ACCEPT"
echo "DROP" echo "DROP"
echo "RETURN" echo "RETURN"
__fish_iptables_chains __fish_iptables_chains
end end
### Commands ### Commands

View file

@ -1,9 +1,5 @@
set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1') set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1')
set -l commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart \ set -l commands list-units list-sockets start stop reload restart try-restart reload-or-restart reload-or-try-restart isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root
isolate kill is-active is-failed status show get-cgroup-attr set-cgroup-attr unset-cgroup-attr set-cgroup help \
reset-failed list-unit-files enable disable is-enabled reenable preset mask unmask link load list-jobs cancel dump \
list-dependencies snapshot delete daemon-reload daemon-reexec show-environment set-environment unset-environment \
default rescue emergency halt poweroff reboot kexec exit suspend hibernate hybrid-sleep switch-root
if test $systemd_version -gt 208 if test $systemd_version -gt 208
set commands $commands cat set commands $commands cat
if test $systemd_version -gt 217 if test $systemd_version -gt 217
@ -13,21 +9,17 @@ end
set -l types services sockets mounts service_paths targets automounts timers set -l types services sockets mounts service_paths targets automounts timers
function __fish_systemd_properties function __fish_systemd_properties
if type -q /usr/lib/systemd/systemd if type -q /usr/lib/systemd/systemd
set IFS "=" /usr/lib/systemd/systemd --dump-configuration-items | string split -m1 = | while read key value
/usr/lib/systemd/systemd --dump-configuration-items | while read key value test -n "$value"
if not test -z $value and echo $key
echo $key end
end else if type -q /lib/systemd/systemd # Debian has not merged /lib and /usr/lib
end /lib/systemd/systemd --dump-configuration-items | string split -m1 = | while read key value
else if type -q /lib/systemd/systemd # Debian has not merged /lib and /usr/lib test -n "$value"
set IFS "=" and echo $key
/lib/systemd/systemd --dump-configuration-items | while read key value end
if not test -z $value end
echo $key
end
end
end
end end
function __fish_systemctl_failed function __fish_systemctl_failed
@ -65,9 +57,9 @@ if test $systemd_version -gt 208
end end
for command in $commands_types for command in $commands_types
for t in $types for t in $types
complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)" complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)"
end end
end end
# Handle reset-failed specially because it doesn't apply to unit-files (only units that have been tried can have failed) and a second "--state=" argument doesn't override the earlier one. # Handle reset-failed specially because it doesn't apply to unit-files (only units that have been tried can have failed) and a second "--state=" argument doesn't override the earlier one.
@ -75,16 +67,16 @@ complete -f -c systemctl -n "__fish_seen_subcommand_from reset-failed" -a "(__fi
# Enable/Disable: Only show units with matching state # Enable/Disable: Only show units with matching state
for t in services sockets timers service_paths for t in services sockets timers service_paths
complete -f -c systemctl -n "__fish_seen_subcommand_from enable" -a "(eval __fish_systemctl_$t --state=disabled)" complete -f -c systemctl -n "__fish_seen_subcommand_from enable" -a "(eval __fish_systemctl_$t --state=disabled)"
complete -f -c systemctl -n "__fish_seen_subcommand_from disable" -a "(eval __fish_systemctl_$t --state=enabled)" complete -f -c systemctl -n "__fish_seen_subcommand_from disable" -a "(eval __fish_systemctl_$t --state=enabled)"
end end
# These are useless for the other commands # These are useless for the other commands
# .device in particular creates too much noise # .device in particular creates too much noise
for t in devices slices scopes swaps for t in devices slices scopes swaps
for command in status show list-dependencies for command in status show list-dependencies
complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)" complete -f -c systemctl -n "__fish_seen_subcommand_from $command" -a "(eval __fish_systemctl_$t)"
end end
end end
complete -f -c systemctl -n "__fish_seen_subcommand_from isolate" -a '(__fish_systemctl_targets)' -d 'Target' complete -f -c systemctl -n "__fish_seen_subcommand_from isolate" -a '(__fish_systemctl_targets)' -d 'Target'

View file

@ -1,30 +1,32 @@
# vagrant autocompletion # vagrant autocompletion
function __fish_vagrant_no_command --description 'Test if vagrant has yet to be given the main command' function __fish_vagrant_no_command --description 'Test if vagrant has yet to be given the main command'
set -l cmd (commandline -opc) set -l cmd (commandline -opc)
test (count $cmd) -eq 1 test (count $cmd) -eq 1
end end
function __fish_vagrant_using_command function __fish_vagrant_using_command
set -l cmd (commandline -opc) set -l cmd (commandline -opc)
set -q cmd[2]; and test "$argv[1]" = $cmd[2] set -q cmd[2]
and test "$argv[1]" = $cmd[2]
end end
function __fish_vagrant_using_command_and_no_subcommand function __fish_vagrant_using_command_and_no_subcommand
set -l cmd (commandline -opc) set -l cmd (commandline -opc)
test (count $cmd) -eq 2; and test "$argv[1]" = "$cmd[2]" test (count $cmd) -eq 2
and test "$argv[1]" = "$cmd[2]"
end end
function __fish_vagrant_using_subcommand --argument-names cmd_main cmd_sub function __fish_vagrant_using_subcommand --argument-names cmd_main cmd_sub
set -l cmd (commandline -opc) set -l cmd (commandline -opc)
set -q cmd[3]; and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3] set -q cmd[3]
and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3]
end end
function __fish_vagrant_boxes --description 'Lists all available Vagrant boxes' function __fish_vagrant_boxes --description 'Lists all available Vagrant boxes'
set -l IFS \n\ \t command vagrant box list | while read -l name _
command vagrant box list | while read -l name _ echo $name
echo $name end
end
end end
# --version and --help are always active # --version and --help are always active

View file

@ -2,8 +2,7 @@ function __fish_complete_lpr_option --description 'Complete lpr option'
set -l optstr (commandline -t) set -l optstr (commandline -t)
switch $optstr switch $optstr
case '*=*' case '*=*'
set -l IFS = string split -m1 = -- "$optstr" | read -l opt val
echo $optstr | read -l opt val
set -l descr set -l descr
for l in (lpoptions -l ^/dev/null | string match -- "*$opt*" | string replace -r '.*/(.*):\s*(.*)$' '$1 $2' | string split " ") for l in (lpoptions -l ^/dev/null | string match -- "*$opt*" | string replace -r '.*/(.*):\s*(.*)$' '$1 $2' | string split " ")
if not set -q descr[1] if not set -q descr[1]

View file

@ -265,8 +265,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
# Use fetch config to fix upstream # Use fetch config to fix upstream
set -l fetch_val (command git config "$cur_prefix".fetch) set -l fetch_val (command git config "$cur_prefix".fetch)
if test -n "$fetch_val" if test -n "$fetch_val"
set -l IFS : string split -m1 : -- "$fetch_val" | read -l trunk pattern
echo "$fetch_val" | read -l trunk pattern
set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream
end end
end end

View file

@ -15,8 +15,6 @@ function __fish_print_help --description "Print help message for the specified f
return return
end end
set -l IFS \n\ \t
# Render help output, save output into the variable 'help' # Render help output, save output into the variable 'help'
set -l help set -l help
set -l cols set -l cols

View file

@ -56,25 +56,21 @@ function funced --description 'Edit function definition'
end end
if test "$editor" = fish if test "$editor" = fish
set -l IFS
if functions -q -- $funcname if functions -q -- $funcname
# Shadow IFS here to avoid array splitting in command substitution functions -- $funcname | fish_indent --no-indent | read -z init
set init (functions -- $funcname | fish_indent --no-indent)
end end
set -l prompt 'printf "%s%s%s> " (set_color green) '$funcname' (set_color normal)' set -l prompt 'printf "%s%s%s> " (set_color green) '$funcname' (set_color normal)'
# Unshadow IFS since the fish_title breaks otherwise
set -e IFS
if read -p $prompt -c "$init" -s cmd if read -p $prompt -c "$init" -s cmd
# Shadow IFS _again_ to avoid array splitting in command substitution echo -n $cmd | fish_indent | read -lz cmd
set -l IFS eval "$cmd"
eval (echo -n $cmd | fish_indent)
end end
return 0 return 0
end end
# OSX mktemp is rather restricted - no suffix, no way to automatically use TMPDIR # OS X (macOS) `mktemp` is rather restricted - no suffix, no way to automatically use TMPDIR.
# Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that it's a fish file # Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that
# it's a fish file.
set -q TMPDIR set -q TMPDIR
or set -l TMPDIR /tmp or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX) set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)

View file

@ -14,19 +14,19 @@ function mktemp
set -l opts set -l opts
while set -q argv[1] while set -q argv[1]
switch $argv[1] switch $argv[1]
case -d case -d
set opts $opts d set opts $opts d
case -t case -t
set opts $opts t set opts $opts t
case -- case --
set -e argv[1] set -e argv[1]
break break
case '-*' case '-*'
echo "mktemp: unknown flag $argv[1]" >&2 echo "mktemp: unknown flag $argv[1]" >&2
_mktemp_help >&2 _mktemp_help >&2
exit 2 exit 2
case '*' case '*'
break break
end end
set -e argv[1] set -e argv[1]
end end
@ -50,8 +50,7 @@ function mktemp
# So let's outlaw them anywhere besides the end. # So let's outlaw them anywhere besides the end.
# Similarly GNU sed requires at least 3 X's, BSD sed requires none. Let's require 3. # Similarly GNU sed requires at least 3 X's, BSD sed requires none. Let's require 3.
begin begin
set -l IFS set -l chars (string split '' -- $template)
printf '%s' "$template" | read -la chars
set -l found_x set -l found_x
for c in $chars for c in $chars
if test $c = X if test $c = X
@ -75,10 +74,10 @@ function mktemp
end end
if contains t $opts if contains t $opts
switch $template switch $template
case '/*' case '/*'
echo "mktemp: invalid template '$template' with -t, template must not be absolute" >&2 echo "mktemp: invalid template '$template' with -t, template must not be absolute" >&2
_mktemp_help >&2 _mktemp_help >&2
exit 1 exit 1
end end
if set -q TMPDIR[1] if set -q TMPDIR[1]