1355  /* Set all the option flags according to the switches specified.
 1356     Return the index of the first non-option argument.  */
 1357
 1358  static int
 1359  decode_switches (int argc, char **argv)
 1360  {
 1361    int c;
 1362    char *time_style_option = NULL;
 1363
 1364    /* Record whether there is an option specifying sort type.  */
 1365    bool sort_type_specified = false;
 1366
 1367    qmark_funny_chars = false;
 1368
 1369    /* initialize all switches to default settings */
 1370
 1371    switch (ls_mode)
 1372      {
 1373      case LS_MULTI_COL:
 1374        /* This is for the `dir' program.  */
 1375        format = many_per_line;
 1376        set_quoting_style (NULL, escape_quoting_style);
 1377        break;
ls/set_quoting_style デフォルトのstyleオプションをescape_quoting_styleにしている。

 1378
 1379      case LS_LONG_FORMAT:
 1380        /* This is for the `vdir' program.  */
 1381        format = long_format;
 1382        set_quoting_style (NULL, escape_quoting_style);
 1383        break;
 1384
 1385      case LS_LS:
 1386        /* This is for the `ls' program.  */
 1387        if (isatty (STDOUT_FILENO))
 1388          {
 1389            format = many_per_line;
 1390            /* See description of qmark_funny_chars, above.  */
 1391            qmark_funny_chars = true;
 1392          }
 1393        else
 1394          {
 1395            format = one_per_line;
 1396            qmark_funny_chars = false;
 1397          }
 1398        break;
 1399
 1400      default:
 1401        abort ();
 1402      }
 1403
 1404    time_type = time_mtime;
 1405    sort_type = sort_name;
 1406    sort_reverse = false;
 1407    numeric_ids = false;
 1408    print_block_size = false;
 1409    indicator_style = none;
 1410    print_inode = false;
 1411    dereference = DEREF_UNDEFINED;
 1412    recursive = false;
 1413    immediate_dirs = false;
 1414    ignore_mode = IGNORE_DEFAULT;
 1415    ignore_patterns = NULL;
 1416    hide_patterns = NULL;
 1417
 1418    /* FIXME: put this in a function.  */
 1419    {
 1420      char const *q_style = getenv ("QUOTING_STYLE");
 1421      if (q_style)
 1422        {
 1423          int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
 1424          if (0 <= i)
 1425            set_quoting_style (NULL, quoting_style_vals[i]);
 1426          else
 1427            error (0, 0,
 1428           _("ignoring invalid value of environment variable QUOTING_STYLE: %s"),
 1429                   quotearg (q_style));
 1430        }
 1431    }
 1432
 1433    {
 1434      char const *ls_block_size = getenv ("LS_BLOCK_SIZE");
 1435      human_output_opts = human_options (ls_block_size, false,
 1436                                         &output_block_size);
 1437      if (ls_block_size || getenv ("BLOCK_SIZE"))
 1438        file_output_block_size = output_block_size;
 1439    }
最終更新:2011年06月26日 11:03