>From 2a216acd3a52f577880d3a8e02eb5dfc2358adf7 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Tue, 16 Feb 2016 17:20:08 -0500 Subject: [PATCH] ls: allow setting default quoting at build time Allows changing the default quoting style for 'ls' during compilation as a 'configure' option: ./configure --enable-ls-default-quoting-style=[STYLE] where STYLE is c|literal|shell|shell-always|locale|escape. Using 'ls --quoting-style' or QUOTING_STYLE env-var can override the default. 'literal' was the default until version 8.24. 'shell' is the default from 8.25 onwards. See also: commit 109b9220cead6e979d22d16327c4d9f8350431cc http://bugs.gnu.org/22696 * configure.ac: new option: --enable-ls-default-quoting-style , will be #define'd in config.h * src/ls.c: use default style value from config file. --- configure.ac | 24 ++++++++++++++++++++++++ src/ls.c | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a484601..efe64ea 100644 --- a/configure.ac +++ b/configure.ac @@ -243,6 +243,30 @@ if test "$gl_single_binary" = 'symlinks'; then fi AM_CONDITIONAL([SINGLE_BINARY], [test "$gl_single_binary" != no]) + + +AC_ARG_ENABLE([ls-default-quoting-style], + [AS_HELP_STRING([--enable-ls-default-quoting-style=[literal|locale|shell|shell-always|c|escape]], + ['ls' default quoting style when printing to stdout, + can be overriden by 'ls --quoting-style=WORD' and + the 'QUOTING_STYLE' environment variable])], + [gl_ls_default_quote_style=shell_escape_quoting_style ; + case $enableval in + literal) gl_ls_default_quote_style=literal_quoting_style ;; + locale) gl_ls_default_quote_style=locale_quoting_style ;; + shell) gl_ls_default_quote_style=shell_escape_quoting_style ;; + shell-always) gl_ls_default_quote_style=shell_escape_always_quoting_style ;; + c) gl_ls_default_quote_style=c_quoting_style ;; + escape) gl_ls_default_quote_style=escape_quoting_style ;; + *) AC_MSG_ERROR([bad value $enableval for ls-default-quoting-style option. + Options are: literal|locale|shell|shell-always|c|escape.]) ;; + esac], + [gl_ls_default_quote_style=shell_escape_quoting_style] +) +AC_DEFINE_UNQUOTED([LS_DEFAULT_QUOTING_STYLE], [$gl_ls_default_quote_style], [Default quoting style for ls]) + + + AC_FUNC_FORK optional_bin_progs= diff --git a/src/ls.c b/src/ls.c index d976036..eea2da5 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1581,7 +1581,7 @@ decode_switches (int argc, char **argv) if (isatty (STDOUT_FILENO)) { format = many_per_line; - set_quoting_style (NULL, shell_escape_quoting_style); + set_quoting_style (NULL, LS_DEFAULT_QUOTING_STYLE); /* See description of qmark_funny_chars, above. */ qmark_funny_chars = true; } -- 1.9.1