[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Нужен ли bash



On Mon, Sep 29, 2008 at 11:26:34AM +0400, Grey Fenrir wrote:
> Не драки ради, а токмо для самообразования.
> Любопытно, как _негнутые_ утилиты обработают, скажем, файл с именем "-f"
> Как справится гнутая (<команда> <ключи> -- <файлы>) мне понятно, а
> какие есть инструменты для этого в стандарте?

Точно такие же.

The getopt() function shall return the next option character (if one is
found) from argv that matches a character in optstring, if there is one
that matches. If the option takes an argument, getopt() shall  set  the
variable optarg to point to the option-argument as follows:

 1. If the option was the last character in the string pointed to by an
    element of argv, then optarg shall  contain  the  next  element  of
    argv,  and optind shall be incremented by 2. If the resulting value
    of optind is greater than argc, this indicates  a  missing  option-
    argument, and getopt() shall return an error indication.

 2. Otherwise,  optarg  shall  point to the string following the option
    character in that element of argv, and optind shall be  incremented
    by 1.

If, when getopt() is called:

       argv[optind]  is a null pointer*
       argv[optind]  is not the character -
       argv[optind]  points to the string "-"

getopt() shall return -1 without changing optind. If:

       argv[optind]   points to the string "--"

getopt() shall return -1 after incrementing optind.

-- 
Andrey V. Kiselev
ICQ# 26871517


Reply to: