i++;
break;
}
+ /*
+ * Compatibility: Prior to 0.5.5 it was necessary to specify
+ * the listing mode without the '=' character as in -lv, for
+ * example. Now the variant with '=' is preferred and
+ * documented but we still accept the old way to specify the
+ * listing mode.
+ *
+ * Support for the legacy syntax can be dropped at 0.6.0
+ * or later.
+ */
if (!strncmp(arg, "-l", 2)) {
- if (!*(arg + 2)) {
- mode = LS_MODE_LONG;
- continue;
- }
- if (*(arg + 3))
- return -E_AFT_SYNTAX;
- switch(*(arg + 2)) {
+ arg += 2;
+ if (*arg == '=')
+ arg++;
+ switch (*arg) {
case 's':
mode = LS_MODE_SHORT;
continue;
case 'l':
+ case '\0':
mode = LS_MODE_LONG;
continue;
case 'v':
flags |= LS_FLAG_UNIXDATE;
continue;
}
+ /* The compatibility remark above applies also to -s. */
if (!strncmp(arg, "-s", 2)) {
- if (!*(arg + 2) || *(arg + 3))
- return -E_AFT_SYNTAX;
- switch(*(arg + 2)) {
+ arg += 2;
+ if (*arg == '=')
+ arg++;
+ switch (*arg) {
case 'p':
sort = LS_SORT_BY_PATH;
continue;