Set cut_dir properly, and add mode line for Emacs.
[gnulib.git] / gnulib-tool
index 78828e5..cb643a7 100755 (executable)
@@ -123,12 +123,24 @@ fi
 # outputs to stdout the --help usage message.
 func_usage ()
 {
+  # This use of bold display can be removed on 2011-01-01.
+  if case "$TERM" in
+       xterm*) test -t 1;;
+       *) false;;
+     esac; then
+    # Assume xterm compatible escape sequences.
+    bold_on=`printf '\x1b[1m'`
+    bold_off=`printf '\x1b[0m'`
+  else
+    bold_on=
+    bold_off=
+  fi
   echo "\
 Usage: gnulib-tool --list
-       gnulib-tool --find filename
+       gnulib-tool --find filename${bold_on}
        gnulib-tool --import [module1 ... moduleN]
        gnulib-tool --add-import [module1 ... moduleN]
-       gnulib-tool --remove-import [module1 ... moduleN]
+       gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
        gnulib-tool --update
        gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
        gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
@@ -151,15 +163,16 @@ Usage: gnulib-tool --list
        gnulib-tool --copy-file file [destination]
 
 Operation modes:
+
       --list                print the available module names
-      --find                find the modules which contain the specified file
+      --find                find the modules which contain the specified file${bold_on}
       --import              import the given modules into the current package
       --add-import          augment the list of imports from gnulib into the
                             current package, by adding the given modules;
                             if no modules are specified, update the current
                             package from the current gnulib
       --remove-import       reduce the list of imports from gnulib into the
-                            current package, by removing the given modules
+                            current package, by removing the given modules${bold_off}
       --update              update the current package, restore files omitted
                             from version control
       --create-testdir      create a scratch package with the given modules
@@ -187,6 +200,7 @@ Operation modes:
       --copy-file                  copy a file that is not part of any module
 
 General options:
+
       --dir=DIRECTORY       Specify the target directory.
                             For --import, this specifies where your
                             configure.ac can be found.  Defaults to current
@@ -198,10 +212,13 @@ General options:
       --verbose             Increase verbosity. May be repeated.
       --quiet               Decrease verbosity. May be repeated.
 
-Options for --import, --update:
+Options for --import, --add/remove-import, --update:
+
       --dry-run             Only print what would have been done.
 
-Options for --import, --create-[mega]testdir, --[mega]test:
+Options for --import, --add/remove-import,
+            --create-[mega]testdir, --[mega]test:
+
       --with-tests          Include unit tests for the included modules.
       --with-obsolete       Include obsolete modules when they occur among the
                             dependencies. By default, dependencies to obsolete
@@ -221,7 +238,8 @@ Options for --import, --create-[mega]testdir, --[mega]test:
       --libtool             Use libtool rules.
       --no-libtool          Don't use libtool rules.
 
-Options for --import:
+Options for --import, --add/remove-import:
+
       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
       --source-base=DIRECTORY
                             Directory relative to --dir where source code is
@@ -236,7 +254,7 @@ Options for --import:
                             Directory relative to --dir where unit tests are
                             placed (default \"tests\").
       --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
-                            tools are placed (default \"build-aux\").
+                            tools are placed (default comes from configure.ac).
       --lgpl[=2|=3]         Abort if modules aren't available under the LGPL.
                             Also modify license template from GPL to LGPL.
                             The version number of the LGPL can be specified;
@@ -254,6 +272,7 @@ Options for --import:
       --no-changelog        Don't update or create ChangeLog files.
 
 Options for --create-[mega]testdir, --[mega]test:
+
       --without-c++-tests   Exclude unit tests for C++ interoperability.
       --without-longrunning-tests
                             Exclude unit tests that are long-runners.
@@ -262,12 +281,15 @@ Options for --create-[mega]testdir, --[mega]test:
       --without-unportable-tests
                             Exclude unit tests that fail on some platforms.
 
-Options for --import, --update, --create-[mega]testdir, --[mega]test:
+Options for --import, --add/remove-import, --update,
+            --create-[mega]testdir, --[mega]test:
+
   -s, --symbolic, --symlink Make symbolic links instead of copying files.
       --local-symlink       Make symbolic links instead of copying files, only
                             for files from the local override directory.
 
-Options for --import, --update:
+Options for --import, --add/remove-import, --update:
+
   -S, --more-symlinks       Make symbolic links instead of copying files, and
                             don't replace copyright notices.
 
@@ -824,20 +846,24 @@ fi
 # that the top-level statement containing the test starts after the 'alias'
 # command.
 if test -z "$have_echo"; then
-bsd_echo ()
+  bsd_echo ()
 {
 cat <<EOF
 $*
 EOF
 }
-alias echo=bsd_echo 2>/dev/null
+  if (alias echo=bsd_echo) 2>/dev/null; then
+    alias echo=bsd_echo 2>/dev/null
+  fi
 fi
 if test -z "$have_echo" \
    && echo '\t' | grep t > /dev/null; then
   have_echo=yes
 fi
 if test -z "$have_echo"; then
-  unalias echo 2>/dev/null
+  if (alias echo=bsd_echo) 2>/dev/null; then
+    unalias echo 2>/dev/null
+  fi
 fi
 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
 if test -z "$have_echo" \
@@ -1591,11 +1617,11 @@ if $modcache; then
       #   ${param//pattern/replacement}
       # as a shorthand for
       #   `echo "$param" | sed -e "s/pattern/replacement/g"`.
-      # Note: The 'eval' above silences stderr output in dash.
-      func_cache_var ()
+      # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
+      eval 'func_cache_var ()
       {
         cachevar=c_${1//[!a-zA-Z0-9_]/_}
-      }
+      }'
     else
       func_cache_var ()
       {
@@ -1780,7 +1806,7 @@ if $modcache; then
   func_cache_lookup_module ()
   {
     if $have_associative; then
-      cached=${modcache_cached[$1]}
+      eval 'cached=${modcache_cached[$1]}'
     else
       func_cache_var "$1"
       eval "cached=\"\$${cachevar}_cached\""
@@ -1789,7 +1815,7 @@ if $modcache; then
       # Not found in cache. Look it up on the file system.
       func_lookup_file "modules/$1"
       if $have_associative; then
-        modcache_cached[$1]=yes
+        eval 'modcache_cached[$1]=yes'
       else
         eval "${cachevar}_cached=\"\$1\""
       fi
@@ -1824,8 +1850,8 @@ func_get_description ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_description[$1]+set}"; then
-        echo "${modcache_description[$1]}"
+      if eval 'test -n "${modcache_description[$1]+set}"'; then
+        eval 'echo "${modcache_description[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_description_set\""
@@ -1850,8 +1876,8 @@ func_get_comment ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_comment[$1]+set}"; then
-        echo "${modcache_comment[$1]}"
+      if eval 'test -n "${modcache_comment[$1]+set}"'; then
+        eval 'echo "${modcache_comment[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_comment_set\""
@@ -1876,8 +1902,8 @@ func_get_status ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_status[$1]+set}"; then
-        echo "${modcache_status[$1]}"
+      if eval 'test -n "${modcache_status[$1]+set}"'; then
+        eval 'echo "${modcache_status[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_status_set\""
@@ -1902,8 +1928,8 @@ func_get_notice ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_notice[$1]+set}"; then
-        echo "${modcache_notice[$1]}"
+      if eval 'test -n "${modcache_notice[$1]+set}"'; then
+        eval 'echo "${modcache_notice[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_notice_set\""
@@ -1929,7 +1955,7 @@ func_get_applicability ()
     func_cache_lookup_module "$1"
     # Get the field's value, without the final newline.
     if $have_associative; then
-      my_applicability="${modcache_applicability[$1]}"
+      eval 'my_applicability="${modcache_applicability[$1]}"'
     else
       eval "my_applicability=\"\$${cachevar}_applicability\""
     fi
@@ -1958,8 +1984,8 @@ func_get_filelist ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_files[$1]+set}"; then
-        echo "${modcache_files[$1]}"
+      if eval 'test -n "${modcache_files[$1]+set}"'; then
+        eval 'echo "${modcache_files[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_files_set\""
@@ -2049,8 +2075,8 @@ func_get_dependencies ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_dependson[$1]+set}"; then
-        echo "${modcache_dependson[$1]}"
+      if eval 'test -n "${modcache_dependson[$1]+set}"'; then
+        eval 'echo "${modcache_dependson[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_dependson_set\""
@@ -2075,8 +2101,8 @@ func_get_autoconf_early_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_configureac_early[$1]+set}"; then
-        echo "${modcache_configureac_early[$1]}"
+      if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
+        eval 'echo "${modcache_configureac_early[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_configureac_early_set\""
@@ -2101,8 +2127,8 @@ func_get_autoconf_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_configureac[$1]+set}"; then
-        echo "${modcache_configureac[$1]}"
+      if eval 'test -n "${modcache_configureac[$1]+set}"'; then
+        eval 'echo "${modcache_configureac[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_configureac_set\""
@@ -2127,8 +2153,8 @@ func_get_automake_snippet ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_makefile[$1]+set}"; then
-        echo "${modcache_makefile[$1]}"
+      if eval 'test -n "${modcache_makefile[$1]+set}"'; then
+        eval 'echo "${modcache_makefile[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_makefile_set\""
@@ -2165,8 +2191,8 @@ func_get_automake_snippet ()
             sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
           else
             if $have_associative; then
-              if test -n "${modcache_makefile[$1]+set}"; then
-                echo "${modcache_makefile[$1]}"
+              if eval 'test -n "${modcache_makefile[$1]+set}"'; then
+                eval 'echo "${modcache_makefile[$1]}"'
               fi
             else
               eval 'field_set="$'"${cachevar}"'_makefile_set"'
@@ -2242,8 +2268,8 @@ func_get_include_directive ()
       func_cache_lookup_module "$1"
       # Output the field's value, including the final newline (if any).
       if $have_associative; then
-        if test -n "${modcache_include[$1]+set}"; then
-          echo "${modcache_include[$1]}"
+        if eval 'test -n "${modcache_include[$1]+set}"'; then
+          eval 'echo "${modcache_include[$1]}"'
         fi
       else
         eval "field_set=\"\$${cachevar}_include_set\""
@@ -2269,8 +2295,8 @@ func_get_link_directive ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_link[$1]+set}"; then
-        echo "${modcache_link[$1]}"
+      if eval 'test -n "${modcache_link[$1]+set}"'; then
+        eval 'echo "${modcache_link[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_link_set\""
@@ -2296,8 +2322,8 @@ func_get_license ()
       func_cache_lookup_module "$1"
       # Output the field's value, including the final newline (if any).
       if $have_associative; then
-        if test -n "${modcache_license[$1]+set}"; then
-          echo "${modcache_license[$1]}"
+        if eval 'test -n "${modcache_license[$1]+set}"'; then
+          eval 'echo "${modcache_license[$1]}"'
         fi
       else
         eval "field_set=\"\$${cachevar}_license_set\""
@@ -2325,8 +2351,8 @@ func_get_maintainer ()
     func_cache_lookup_module "$1"
     # Output the field's value, including the final newline (if any).
     if $have_associative; then
-      if test -n "${modcache_maintainer[$1]+set}"; then
-        echo "${modcache_maintainer[$1]}"
+      if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
+        eval 'echo "${modcache_maintainer[$1]}"'
       fi
     else
       eval "field_set=\"\$${cachevar}_maintainer_set\""
@@ -3551,10 +3577,10 @@ func_import ()
           # Use an associative array, for O(N) worst-case run time.
           declare -A to_remove
           for m in $1; do
-            to_remove[$m]=yes
+            eval 'to_remove[$m]=yes'
           done
           for module in $cached_specified_modules; do
-            if test -z "${to_remove[$module]}"; then
+            if eval 'test -z "${to_remove[$module]}"'; then
               func_append specified_modules "$module "
             fi
           done