.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "ARGPARSE" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME argparse \- parse options passed to a fish script or function .SH SYNOPSIS .nf \fBargparse\fP [\fIOPTIONS\fP] \fIOPTION_SPEC\fP \&... \fB\-\-\fP [\fIARG\fP \&...] .fi .sp .SH DESCRIPTION .sp This command makes it easy for fish scripts and functions to handle arguments. You pass arguments that define the known options, followed by a literal \fB\-\-\fP, then the arguments to be parsed (which might also include a literal \fB\-\-\fP). \fBargparse\fP then sets variables to indicate the passed options with their values, sets \fB$argv_opts\fP to the options and their values, and sets \fB$argv\fP to the remaining arguments. See the \fI\%usage\fP section below. .sp Each option specification (\fBOPTION_SPEC\fP) is written in the \fI\%domain specific language\fP described below. All OPTION_SPECs must appear after any argparse flags and before the \fB\-\-\fP that separates them from the arguments to be parsed. .sp Each option that is seen in the ARG list will result in variables named \fB_flag_X\fP, where \fBX\fP is the short flag letter and the long flag name (if they are defined). For example a \fB\-\-help\fP option could cause argparse to define one variable called \fB_flag_h\fP and another called \fB_flag_help\fP\&. .sp The variables will be set with local scope (i.e., as if the script had done \fBset \-l _flag_X\fP). If the flag is a boolean (that is, it is passed or not, it doesn\(aqt have a value) the values are the short and long flags seen. If the option is not a boolean the values will be zero or more values corresponding to the values collected when the ARG list is processed. If the flag was not seen the flag variable will not be set. .SH OPTIONS .sp The following \fBargparse\fP options are available. They must appear before all \fIOPTION_SPEC\fPs: .INDENT 0.0 .TP \fB\-n\fP or \fB\-\-name\fP \fINAME\fP Use \fINAME\fP in error messages. By default the current function name will be used, or \fBargparse\fP if run outside of a function. .TP \fB\-x\fP or \fB\-\-exclusive\fP \fIOPTIONS\fP A comma separated list of options that are mutually exclusive. You can use this more than once to define multiple sets of mutually exclusive options. You give either the short or long version of each option, and you still need to otherwise define the options. .TP \fB\-N\fP or \fB\-\-min\-args\fP \fINUMBER\fP The minimum number of acceptable non\-option arguments. The default is zero. .TP \fB\-X\fP or \fB\-\-max\-args\fP \fINUMBER\fP The maximum number of acceptable non\-option arguments. The default is infinity. .TP \fB\-u\fP or \fB\-\-move\-unknown\fP Allow unknown options, and move them from \fB$argv\fP to \fB$argv_opts\fP\&. By default, Unknown options are treated as if they take optional arguments (i.e. have option spec \fB=?\fP). .sp The above means that if a group of short options contains an unknown short option \fIfollowed\fP by a known short option, the known short option is treated as an argument to the unknown one (e.g. \fB\-\-move\-unknown h \-\- \-oh\fP will treat \fBh\fP as the argument to \fB\-o\fP, and so \fB_flag_h\fP will \fInot\fP be set). In contrast, if the known option comes first (and does not take any arguments), the known option will be recognised (e.g. \fBargparse \-\-move\-unknown h \-\- \-ho\fP \fIwill\fP set \fB$_flag_h\fP to \fB\-h\fP) .TP \fB\-i\fP or \fB\-\-ignore\-unknown\fP Deprecated. This is like \fB\-\-move\-unknown\fP, except that unknown options and their arguments are kept in \fB$argv\fP and not moved to \fB$argv_opts\fP\&. Unlike \fB\-\-move\-unknown\fP, this option makes it impossible to distinguish between an unknown option and non\-option argument that starts with a \fB\-\fP (since any \fB\-\-\fP seperator in \fB$argv\fP will be removed). .TP \fB\-S\fP or \fB\-\-strict\-longopts\fP This makes the parsing of long options more strict. In particular, \fIwithout\fP this flag, if \fBlong\fP is a known long option flag, \fB\-\-long\fP and \fB\-\-long=\fP can be abbreviated as: .INDENT 7.0 .IP \(bu 2 \fB\-long\fP and \fB\-long=\fP, but \fIonly\fP if there is no short flag \fBl\fP\&. .IP \(bu 2 \fB\-\-lo\fP and \fB\-\-lo=\fP, but \fIonly\fP if there is no other long flag that starts with \fBlo\fP\&. Similarly with any other non\-empty prefix of \fBlong\fP\&. .IP \(bu 2 \fB\-lo\fP and \fB\-lo=\fP (i.e. combining the above two). .UNINDENT .sp With the \fB\-\-strict\-longopts\fP flag, the above three are parse errors: one must use the syntax \fB\-\-long\fP or \fB\-\-long=\fP to use a long option called \fBlong\fP\&. .sp This flag has no effect on the parsing of unknown options (which are parsed as if this flag is on). .sp This option may be on all the time in the future, so do not rely on the behaviour without it. .TP \fB\-\-unknown\-arguments\fP \fIKIND\fP This option implies \fB\-\-move\-unknown\fP, unless \fB\-\-ignore\-unknown\fP is also given. This will modify the parsing behaviour of unknown options depending on the value of \fIKIND\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fBoptional\fP (the default), allows each unknown option to take an optional argument (i.e. as if it had \fB=?\fP or \fB=*\fP in its option specification). For example, \fBargparse \-\-ignore\-unknown \-\-unknown\-arguments=optional ab \-\- \-u \-a \-ub\fP will set \fB_flag_a\fP but \fInot\fP \fB_flag_b\fP, as the \fBb\fP is treated as an argument to the second use of \fB\-u\fP\&. .IP \(bu 2 \fBrequired\fP requires each unknown option to take an argument (i.e. as if it had \fB=\fP or \fB=+\fP in its option specification). If the above example was changed to use \fB\-\-unknown\-arguments=required\fP, \fIneither\fP \fB_flag_a\fP nor \fB_flag_b\fP would be set: the \fB\-a\fP will be treated as an argument to the first use of \fB\-u\fP, and the \fBb\fP as an argument to the second. .IP \(bu 2 \fBnone\fP forbids each unknown option from taking an argument (i.e. as if it had no \fB=\fP in its option specification). If the above example was changed to use \fB\-\-unknown\-arguments=none\fP, \fIboth\fP \fB_flag_a\fP and \fB_flag_b\fP would be set, as neither use of \fB\-u\fP will be passed as taking an argument. .UNINDENT .sp Note that the above assumes that unknown long flags use the \fB\-\-\fP \(dqGNU\-style\(dq (e.g. if \fIKIND\fP is \fBnone\fP, and there is no \fBbar\fP long option, \fB\-bar\fP is interpreted as three short flags, \fBb\fP, \fBa\fP, and \fBr\fP; but if \fBbar\fP is known, \fB\-bar\fP is treated the same as \fB\-\-bar\fP). .sp When using \fB\-\-unknown\-arguments=required\fP, you will get an error if the provided arguments end in an unknown option, since it has no argument. Similarly, with \fB\-\-unknown\-arguments=none\fP, you will get an error if you use the \fB\-\-flag=value\fP syntax and \fBflag\fP is an unknown option. .UNINDENT .UNINDENT .TP \fB\-s\fP or \fB\-\-stop\-nonopt\fP Causes scanning the arguments to stop as soon as the first non\-option argument is seen. Among other things, this is useful to implement subcommands that have their own options. .TP \fB\-h\fP or \fB\-\-help\fP Displays help about using this command. .UNINDENT .SH USAGE .sp To use this command, pass the option specifications (\fBOPTION_SPEC\fP), a mandatory \fB\-\-\fP, and then the arguments to be parsed. .sp A simple example: .INDENT 0.0 .INDENT 3.5 .sp .EX argparse \(aqh/help\(aq \(aqn/name=\(aq \-\- $argv or return .EE .UNINDENT .UNINDENT .sp If \fB$argv\fP is empty then there is nothing to parse and \fBargparse\fP returns zero to indicate success. If \fB$argv\fP is not empty then it is checked for flags \fB\-h\fP, \fB\-\-help\fP, \fB\-n\fP and \fB\-\-name\fP\&. If they are found they are removed from the arguments and local variables called \fB_flag_OPTION\fP are set so the script can determine which options were seen. If \fB$argv\fP doesn\(aqt have any errors, like an unknown option or a missing mandatory value for an option, then \fBargparse\fP exits with a status of zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one. .sp The \fBor return\fP means that the function returns \fBargparse\fP\(aqs status if it failed, so if it goes on \fBargparse\fP succeeded. .sp To use the flags argparse has extracted: .INDENT 0.0 .INDENT 3.5 .sp .EX # Checking for _flag_h and _flag_help is equivalent # We check if it has been given at least once if set \-ql _flag_h echo \(dqUsage: my_function [\-h | \-\-help] [\-n | \-\-name=NAME]\(dq >&2 return 1 end set \-l myname somedefault set \-ql _flag_name[1] and set myname $_flag_name[\-1] # here we use the *last* \-\-name= .EE .UNINDENT .UNINDENT .sp Any characters in the flag name that are not valid in a variable name (like \fB\-\fP dashes) will be replaced with underscores. .sp The \fB\-\-\fP argument is required. You do not have to include any option specifications or arguments after the \fB\-\-\fP but you must include the \fB\-\-\fP\&. For example, this is acceptable: .INDENT 0.0 .INDENT 3.5 .sp .EX set \-l argv foo argparse \(aqh/help\(aq \(aqn/name\(aq \-\- $argv argparse \-\-min\-args=1 \-\- $argv .EE .UNINDENT .UNINDENT .sp But this is not: .INDENT 0.0 .INDENT 3.5 .sp .EX set \-l argv argparse \(aqh/help\(aq \(aqn/name\(aq $argv .EE .UNINDENT .UNINDENT .sp The first \fB\-\-\fP seen is what allows the \fBargparse\fP command to reliably separate the option specifications and options to \fBargparse\fP itself (like \fB\-\-move\-unknown\fP) from the command arguments, so it is required. .SH OPTION SPECIFICATIONS .sp Each option specification consists of: .INDENT 0.0 .IP \(bu 2 An optional alphanumeric short flag character. .IP \(bu 2 An optional long flag name preceded by a \fB/\fP\&. If neither a short flag nor long flag are present, an error is reported. .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 If there is no short flag, and the long flag name is more than one character, the \fB/\fP can be omitted. .IP \(bu 2 For backwards compatibility, if there is a short and a long flag, a \fB\-\fP can be used in place of the \fB/\fP, if the short flag is not to be usable by users (in which case it will also not be exposed as a flag variable). .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 Nothing if the flag is a boolean that takes no argument or is an integer flag, or .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB=\fP if it requires a value and only the last instance of the flag is saved, or .IP \(bu 2 \fB=?\fP if it takes an optional value and only the last instance of the flag is saved, or .IP \(bu 2 \fB=+\fP if it requires a value and each instance of the flag is saved, or .IP \(bu 2 \fB=*\fP if it takes an optional value \fIand\fP each instance of the flag is saved, storing the empty string when the flag was not given a value. .UNINDENT .UNINDENT .UNINDENT .IP \(bu 2 Optionally a \fB&\fP, indicating that the option and any attached values are not to be saved in \fB$argv\fP or \fB$argv_opts\fP\&. This does not affect the the \fB_flag_\fP variables. .IP \(bu 2 Nothing if the flag is a boolean that takes no argument, or .INDENT 2.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 \fB!\fP followed by fish script to validate the value. Typically this will be a function to run. If the exit status is zero the value for the flag is valid. If non\-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on \fI\%Flag Value Validation\fP for more information. .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp See the \fI\%fish_opt\fP command for a friendlier but more verbose way to create option specifications. .sp If a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set. .SH INTEGER FLAG .sp Sometimes commands take numbers directly as options, like \fBfoo \-55\fP\&. To allow this one option spec can have the \fB#\fP modifier so that any integer will be understood as this flag, and the last number will be given as its value (as if \fB=\fP was used). .sp The \fB#\fP must follow the short flag letter (if any), and other modifiers like \fB=\fP are not allowed, except for \fB\-\fP (for backwards compatibility): .INDENT 0.0 .INDENT 3.5 .sp .EX m#maximum .EE .UNINDENT .UNINDENT .sp This does not read numbers given as \fB+NNN\fP, only those that look like flags \- \fB\-NNN\fP\&. .SH NOTE: OPTIONAL ARGUMENTS .sp An option defined with \fB=?\fP or \fB=*\fP can take optional arguments. Optional arguments have to be \fIdirectly attached\fP to the option they belong to. .sp That means the argument will only be used for the option if you use it like: .INDENT 0.0 .INDENT 3.5 .sp .EX cmd \-\-flag=value # or cmd \-fvalue .EE .UNINDENT .UNINDENT .sp but not if used like: .INDENT 0.0 .INDENT 3.5 .sp .EX cmd \-\-flag value # \(dqvalue\(dq here will be used as a positional argument # and \(dq\-\-flag\(dq won\(aqt have an argument. .EE .UNINDENT .UNINDENT .sp If this weren\(aqt the case, using an option without an optional argument would be difficult if you also wanted to use positional arguments. .sp For example: .INDENT 0.0 .INDENT 3.5 .sp .EX grep \-\-color auto # Here \(dqauto\(dq will be used as the search string, # \(dqcolor\(dq will not have an argument and will fall back to the default, # which also *happens to be* auto. grep \-\-color always # Here grep will still only use color \(dqauto\(dqmatically # and search for the string \(dqalways\(dq. .EE .UNINDENT .UNINDENT .sp This isn\(aqt specific to argparse but common to all things using \fBgetopt(3)\fP (if they have optional arguments at all). That \fBgrep\fP example is how GNU grep actually behaves. .SH FLAG VALUE VALIDATION .sp Sometimes you need to validate the option values. For example, that it is a valid integer within a specific range, or an ip address, or something entirely different. You can always do this after \fBargparse\fP returns but you can also request that \fBargparse\fP perform the validation by executing arbitrary fish script. To do so append an \fB!\fP (exclamation\-mark) then the fish script to be run. When that code is executed three vars will be defined: .INDENT 0.0 .IP \(bu 2 \fB_argparse_cmd\fP will be set to the value of the value of the \fBargparse \-\-name\fP value. .IP \(bu 2 \fB_flag_name\fP will be set to the short or long flag that being processed. .IP \(bu 2 \fB_flag_value\fP will be set to the value associated with the flag being processed. .UNINDENT .sp These variables are passed to the function as local exported variables. .sp The script should write any error messages to stdout, not stderr. It should return a status of zero if the flag value is valid otherwise a non\-zero status to indicate it is invalid. .sp Fish ships with a \fB_validate_int\fP function that accepts a \fB\-\-min\fP and \fB\-\-max\fP flag. Let\(aqs say your command accepts a \fB\-m\fP or \fB\-\-max\fP flag and the minimum allowable value is zero and the maximum is 5. You would define the option like this: \fBm/max=!_validate_int \-\-min 0 \-\-max 5\fP\&. The default if you call \fB_validate_int\fP without those flags is to check that the value is a valid integer with no limits on the min or max value allowed. .sp Here are some examples of flag validations: .INDENT 0.0 .INDENT 3.5 .sp .EX # validate that a path is a directory argparse \(aqp/path=!test \-d \(dq$_flag_value\(dq\(aq \-\- \-\-path $__fish_config_dir # validate that a function does not exist argparse \(aqf/func=!not functions \-q \(dq$_flag_value\(dq\(aq \-\- \-f alias # validate that a string matches a regex argparse \(aqc/color=!string match \-rq \e\(aq^#?[0\-9a\-fA\-F]{6}$\e\(aq \(dq$_flag_value\(dq\(aq \-\- \-c \(aqc0ffee\(aq # validate with a validator function argparse \(aqn/num=!_validate_int \-\-min 0 \-\-max 99\(aq \-\- \-\-num 42 .EE .UNINDENT .UNINDENT .SH EXAMPLE OPTION_SPECS .sp Some \fIOPTION_SPEC\fP examples: .INDENT 0.0 .IP \(bu 2 \fBh/help\fP means that both \fB\-h\fP and \fB\-\-help\fP are valid. The flag is a boolean and can be used more than once. If either flag is used then \fB_flag_h\fP and \fB_flag_help\fP will be set to however either flag was seen, as many times as it was seen. So it could be set to \fB\-h\fP, \fB\-h\fP and \fB\-\-help\fP, and \fBcount $_flag_h\fP would yield \(dq3\(dq. .IP \(bu 2 \fBhelp\fP means that only \fB\-\-help\fP is valid. The flag is a boolean and can be used more than once. If it is used then \fB_flag_help\fP will be set as above. Also \fBh\-help\fP (with an arbitrary short letter) for backwards compatibility. .IP \(bu 2 \fBhelp&\fP is similar (it will \fIremove\fP \fB\-\-help\fP from \fB$argv\fP), the difference is that \fB\-\-help\(ga\fP will \fInot\fP placed in \fB$argv_opts\fP\&. .IP \(bu 2 \fBlongonly=\fP is a flag \fB\-\-longonly\fP that requires an option, there is no short flag or even short flag variable. .IP \(bu 2 \fBn/name=\fP means that both \fB\-n\fP and \fB\-\-name\fP are valid. It requires a value and can be used at most once. If the flag is seen then \fB_flag_n\fP and \fB_flag_name\fP will be set with the single mandatory value associated with the flag. .IP \(bu 2 \fBn/name=?\fP means that both \fB\-n\fP and \fB\-\-name\fP are valid. It accepts an optional value and can be used at most once. If the flag is seen then \fB_flag_n\fP and \fB_flag_name\fP will be set with the value associated with the flag if one was provided else it will be set with no values. .IP \(bu 2 \fBn/name=*\fP is similar, but the flag can be used more than once. If the flag is seen then \fB_flag_n\fP and \fB_flag_name\fP will be set with the values associated with each occurence. Each value will be the value given to the option, or the empty string if no value was given. .IP \(bu 2 \fBname=+\fP means that only \fB\-\-name\fP is valid. It requires a value and can be used more than once. If the flag is seen then \fB_flag_name\fP will be set with the values associated with each occurrence. .IP \(bu 2 \fBx\fP means that only \fB\-x\fP is valid. It is a boolean that can be used more than once. If it is seen then \fB_flag_x\fP will be set as above. .IP \(bu 2 \fB/x\fP is similar, but only \fB\-\-x\fP is valid (instead of \fB\-x\fP). .IP \(bu 2 \fBx=\fP, \fBx=?\fP, and \fBx=+\fP are similar to the n/name examples above but there is no long flag alternative to the short flag \fB\-x\fP\&. .IP \(bu 2 \fB#max\fP (or \fB#\-max\fP) means that flags matching the regex \(dq^\-\-?\ed+$\(dq are valid. When seen they are assigned to the variable \fB_flag_max\fP\&. This allows any valid positive or negative integer to be specified by prefixing it with a single \(dq\-\(dq. Many commands support this idiom. For example \fBhead \-3 /a/file\fP to emit only the first three lines of /a/file. .IP \(bu 2 \fBn#max\fP means that flags matching the regex \(dq^\-\-?\ed+$\(dq are valid. When seen they are assigned to the variables \fB_flag_n\fP and \fB_flag_max\fP\&. This allows any valid positive or negative integer to be specified by prefixing it with a single \(dq\-\(dq. Many commands support this idiom. For example \fBhead \-3 /a/file\fP to emit only the first three lines of /a/file. You can also specify the value using either flag: \fB\-n NNN\fP or \fB\-\-max NNN\fP in this example. .IP \(bu 2 \fB#longonly\fP causes the last integer option to be stored in \fB_flag_longonly\fP\&. .UNINDENT .sp After parsing the arguments the \fBargv\fP variable is set with local scope to any values not already consumed during flag processing. If there are no unbound values the variable is set but \fBcount $argv\fP will be zero. Similarly, the \fBargv_opts\fP variable is set with local scope to the arguments that \fIwere\fP consumed during flag processing. This allows forwarding \fB$argv_opts\fP to another command, together with additional arguments. .sp If an error occurs during argparse processing it will exit with a non\-zero status and print error messages to stderr. .SH EXAMPLES .sp A simple use: .INDENT 0.0 .INDENT 3.5 .sp .EX argparse h/help \-\- $argv or return if set \-q _flag_help # TODO: Print help here return 0 end .EE .UNINDENT .UNINDENT .sp This supports one option \- \fB\-h\fP / \fB\-\-help\fP\&. Any other option is an error. If it is given it prints help and exits. .sp How \fI\%fish_add_path \- add to the path\fP parses its args: .INDENT 0.0 .INDENT 3.5 .sp .EX argparse \-x g,U \-x P,U \-x a,p g/global U/universal P/path p/prepend a/append h/help m/move v/verbose n/dry\-run \-\- $argv .EE .UNINDENT .UNINDENT .sp There are a variety of boolean flags, all with long and short versions. A few of these cannot be used together, and that is what the \fB\-x\fP flag is used for. \fB\-x g,U\fP means that \fB\-\-global\fP and \fB\-\-universal\fP or their short equivalents conflict, and if they are used together you get an error. In this case you only need to give the short or long flag, not the full option specification. .sp After this it figures out which variable it should operate on according to the \fB\-\-path\fP flag: .INDENT 0.0 .INDENT 3.5 .sp .EX set \-l var fish_user_paths set \-q _flag_path and set var PATH # ... # Check for \-\-dry\-run. # The \(dq\-\(dq has been replaced with a \(dq_\(dq because # it is not valid in a variable name not set \-ql _flag_dry_run and set $var $result .EE .UNINDENT .UNINDENT .sp An example of using \fB$argv_opts\fP to forward known options to another command, whilst adding new options: .INDENT 0.0 .INDENT 3.5 .sp .EX function my\-head # The following option is the only existing one to head that takes arguments # (we will forward it verbatim). set \-l opt_spec n/lines= # \-\-qwords is a new option, but \-\-bytes is an existing one which we will modify below set \-a opt_spec \(dqqwords=&\(dq \(dqc/bytes=&\(dq argparse \-\-strict\-longopts \-\-move\-unknown \-\-unknown\-arguments=none $opt_spec \-\- $argv || return if set \-q _flag_qwords # \-\-qwords allows specifying the size in multiples of 8 bytes set \-a argv_opts \-\-bytes=(math \-\- $_flag_qwords \e* 8 || return) else if set \-q _flag_bytes # Allows using a \(aqq\(aq suffix, e.g. \-\-bytes=4q to mean 4*8 bytes. if string match \-qr \(aqq$\(aq \-\- $_flag_bytes set \-a argv_opts \-\-bytes=(math \-\- (string replace \-r \(aqq$\(aq \(aq*8\(aq \-\- $_flag_bytes) || return) else # Keep the users setting set \-a argv_opts \-\-bytes=$_flag_bytes end end if test (count $argv) \-eq 0 # Default to heading /dev/kmsg (whereas head defaults to stdin) set \-l argv /dev/kmsg end # Call the real head with our modified options and arguments. head $argv_opts \-\- $argv end .EE .UNINDENT .UNINDENT .sp The argparse call above saves all the options we do \fInot\fP want to process in \fB$argv_opts\fP\&. (The \fB\-\-qwords\fP and \fB\-\-bytes\fP options are \fInot\fP saved there as their option spec\(aqs end in a \fB~\fP). The code then processes the \fB\-\-qwords\fP and \fB\-\-bytess\fP options using the the \fB$_flag_OPTION\fP variables, and puts the transformed options in \fB$argv_opts\fP (which already contains all the original options, \fIother\fP than \fB\-\-qwords\fP and \fB\-\-bytes\fP). .sp Note that because the \fBargparse\fP call above uses \fB\-\-move\-unknown\fP and \fB\-\-unknown\-arguments=none\fP, we only need to tell it the arguments to \fBhead\fP that take a value. This allows the wrapper script to accurately work out the \fInon\fP\-option arguments (i.e. \fB$argv\fP, the filenames that \fBhead\fP is to operate on). Using \fB\-\-unknown\-arguments=optional\fP and explicitly listing all the known options to \fBhead\fP however would have the advantage that if \fBhead\fP were to add new options, they could still be used with the wrapper script using the \(dqstuck\(dq form for arguments (e.g. \fB\-o\fP, or \fB\-\-opt=\fP). .sp Note that the \fB\-\-strict\-longopts\fP is required to be able to correctly pass short options, e.g. without it \fBmy\-head \-q \-\-bytes 10q\fP, will actually parse the \fB\-q\fP as shorthand for \fB\-\-qwords\fP\&. .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .