EnglishFrenchSpanish

OnWorks favicon

getopt_long - Online in the Cloud

Run getopt_long in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command getopt_long that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

PROGRAM:

NAME


getopts — libbash library for command line parameters parsing

SYNOPSIS


$retval getopt_long ⟨Instructions⟩ ⟨Parameters⟩

DESCRIPTION


This is a documentation for libbash getopts library, that implements getopt_long function
for bash(1). For documentation of bash getopts function, please see getopts(1) (
getopts(1posix) on some systems).

Here is a table for reference:
getopts(1) (or 1posix on some systems) implemented by bash
getopts(3) implemented by libbash.
getopt(1) implemented by getopt utils (part of util-linux)
getopt_long(1) implemented by libbash and installed to section 1 instead of 3 to prevent
collision with C man pages.
getopt(3) implemented by GNU C library.
getopt_long(3) implemented by GNU C library.
I have also seen separate getopt utility which part of util-linux package.

The getopt_long function parses the command line arguments. It uses Instructions as the
rules for parsing the Parameters.

The Instructions
A string that specifies rules for parameters parsing. The instructions string is built of a
group of independent instructions, separated by a white space. Each instruction must have
the following structure:

-<SingleLetter>|--<MultiLetter>-><VariableName>[:]

This structure contains three parts:

-<SingleLetter>
This is the parameter single-letter sign. For example -h.

--<MultiLetter>
This is the parameter's corresponding multi-letter sign. For example --help.

<VariableName>[:]
This is the name of the variable that will contain the parameter value. For example:
HELP.

The Variable name can represent one of two variables types:

Flag variable (not followed by ‘:’)
In this case, it will hold the value 1 if ‘on’ (i.e. was specified on command
line) and will not be defined if ‘off’.

Value variable (followed by ‘:’)
In this case, the value it will hold is the string that was given as the next
parameter in the Parameters string (Separated by white-space or ‘=’ ). If input
contains more then one instance of the considered command line option, an array
of the given parameters will be set as the value of the variable.

The Parameters
The Parameters are simply the parameters you wish to parse.

RETURN VALUE


This function returns a string that contains a set of variables definitions. In order to
define the variables, this string should be given as a parameter to eval function. This
value is returned in the variable $retval.

EXAMPLES


Parse command line parameters looking for the flags -h | --help and -v | --version and for
the value -p | --path :

getopt_long '-h|--help->HELP
-v|--version->VERSION
-p|--path->PATH:' $*
eval $retval

In this example, for the parameters --help --path=/usr/ the variables that will be created
are:

HELP=1
PATH=/usr/

for the parameters --help --path=/usr --path=/bin the variables that will be created are:

HELP=1
PATH=(/usr /bin)

Use getopt_long online using onworks.net services


Free Servers & Workstations

Download Windows & Linux apps

  • 1
    SAGA GIS
    SAGA GIS
    SAGA - System for Automated
    Geoscientific Analyses - is a Geographic
    Information System (GIS) software with
    immense capabilities for geodata
    processing and ana...
    Download SAGA GIS
  • 2
    Toolbox for Java/JTOpen
    Toolbox for Java/JTOpen
    The IBM Toolbox for Java / JTOpen is a
    library of Java classes supporting the
    client/server and internet programming
    models to a system running OS/400,
    i5/OS, o...
    Download Toolbox for Java/JTOpen
  • 3
    D3.js
    D3.js
    D3.js (or D3 for Data-Driven Documents)
    is a JavaScript library that allows you
    to produce dynamic, interactive data
    visualizations in web browsers. With D3
    you...
    Download D3.js
  • 4
    Shadowsocks
    Shadowsocks
    A fast tunnel proxy that helps you
    bypass firewalls This is an application
    that can also be fetched from
    https://sourceforge.net/projects/shadowsocksgui/.
    It ha...
    Download Shadowsocks
  • 5
    GLPI Themes
    GLPI Themes
    Download release at
    https://github.com/stdonato/glpi-modifications/
    Color themes for GLPI 0.84 and 0.85 New
    Modifications for GLPI This is an
    application that c...
    Download GLPI Themes
  • 6
    SMPlayer
    SMPlayer
    SMPlayer is a free media player for
    Windows and Linux with built-in codecs
    that can also play YouTube videos. One
    of the most interesting features of
    SMPlayer:...
    Download SMPlayer
  • More »

Linux commands

Ad