From 97f6b4319e3c75e14801b2a6e9ea90ae905c0a3d Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Sat, 30 May 2020 18:30:29 -0500 Subject: [PATCH] Remove backticks in top source directory Reasoning is given in the update to README.coding_style. --- README.coding_style | 24 ++++++++++++++++++++++++ README.developer | 18 +++++++++--------- configure.ac | 6 +++--- hamlib.m4 | 13 ++++++------- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/README.coding_style b/README.coding_style index 43738b78e..c99dcc24c 100644 --- a/README.coding_style +++ b/README.coding_style @@ -143,6 +143,30 @@ The old file will be copied to 'moonmelter.c.orig' as a back up. /* NOP unless x is true. */ while (!x); +* Avoid the use of backticks (`) to invoke a subshell, also known as the grave + accent, in shell scripts, configure.ac, any Makefile.am, or .m4 files we + maintain. While their use will likely be long supported, they do require + some care in use and can be difficult to read on the screen. + + The preferred construct is to use parentheses to invoke a subshell and the + '$()' construct when the output of the command is intended to be captured in + a shell variable. This answer covers the reasoning well: + + https://unix.stackexchange.com/a/126928 + + In Makefile.am files use the '$$()' construct to capture subshell command + output into a make variable. + + Exceptions: + + Files intended to be formatted in Markdown syntax use backticks as a + formatting cue. In these files such use is permitted. + + There are a number of files sourced from the GNU Project where the + backtick is used extensively as an opening single quote character. As we + don't usually maintain these files except to update them as needed, these + rules are waived for those files. + 4. Use of code formatting tools diff --git a/README.developer b/README.developer index ec3c49d67..140c068a1 100644 --- a/README.developer +++ b/README.developer @@ -314,7 +314,7 @@ optional as shown using the square brackets.. This will keep the binary output files separate from the source tree and aid in development by reducing clutter in the source tree. -Once you've run `bootstrap', make sure you've got some recent config.guess +Once you've run 'bootstrap', make sure you've got some recent config.guess and config.sub (needed to guess your system type). Anything of at least year 2004 should be fine, unless you run some exotic hardware/software system (modern Linux distributions and Cygwin keep these up to date): @@ -322,7 +322,7 @@ year 2004 should be fine, unless you run some exotic hardware/software system ./config.guess --version ./config.sub --version -The '--prefix' option to `configure' is optional and not shown as it defaults +The '--prefix' option to 'configure' is optional and not shown as it defaults to /usr/local. Convention is that locally built packages be installed in /usr/local away from distribution installed packages. The 'CFLAGS="-g -O0"' environment variable generates less optimized binaries with the '-O0' while the @@ -361,8 +361,8 @@ for this target as neither the bindings or old documentation are generated in a default build. NOTE! If Hamlib has not been previously installed as a locally built -package you will need to make sure that `ldconfig' is configured correctly -and run periodically after `make install'. Most modern distributions have +package you will need to make sure that 'ldconfig' is configured correctly +and run periodically after 'make install'. Most modern distributions have an /etc/ld.so.conf.d/ directory where local configuration can be made. Later versions of Debian and derivatives have a file named 'libc.conf' in this directory. The contents of libc.conf are: @@ -371,7 +371,7 @@ this directory. The contents of libc.conf are: /usr/local/lib If your system does not have such a file, one will need to be created and -then `ldconfig' will need to be run as the root user so that applications +then 'ldconfig' will need to be run as the root user so that applications using the Hamlib libraries can find them. @@ -471,8 +471,8 @@ So far, Hamlib has been tested successfully under the following systems: $ git commit -m "Initial release" Makefile.am mybackend.c mybackend.h - Note: The `-m' switch passes a short message to the Git repository - upon a commit. If a longer message is desired, do not use the `-m' + Note: The '-m' switch passes a short message to the Git repository + upon a commit. If a longer message is desired, do not use the '-m' option. The editor specified in the EDITOR or VISUAL environment variables will be started where a more detailed message may be composed. @@ -498,12 +498,12 @@ So far, Hamlib has been tested successfully under the following systems: 3.6. In initrigs_ of mybackend.c, add "rig_register(&_caps);" - 3.7. Run `make' if you have dependencies, or the following to regenerate + 3.7. Run 'make' if you have dependencies, or the following to regenerate the makefile: $ automake mybackend/Makefile $ CONFIG_HEADERS= CONFIG_LINKS= CONFIG_FILES=mybackend/Makefile ./config.status - Run `make' in topdir to rebuild all. + Run 'make' in topdir to rebuild all. 3.8. Commit your work (once tests are satisfactory): $ git add . diff --git a/configure.ac b/configure.ac index 04ee53770..f9b273820 100644 --- a/configure.ac +++ b/configure.ac @@ -739,7 +739,7 @@ AC_SUBST([BACKENDEPS]) ## ---------------------------------- ## for be in ${RIG_BACKEND_LIST} ; do - RIGDIR=`echo $be | awk -F "/" '{print $2}'` + RIGDIR=$(echo $be | awk -F "/" '{print $2}') RIG_BACKENDEPS="${RIG_BACKENDEPS} \$(top_builddir)/rigs/${RIGDIR}/libhamlib-${RIGDIR}.la" done @@ -754,7 +754,7 @@ AC_SUBST([RIG_BACKENDEPS]) # otherwise parallel 'make -jn' will fail for be in ${ROT_BACKEND_LIST} ; do - ROTDIR=`echo $be | awk -F "/" '{print $2}'` + ROTDIR=$(echo $be | awk -F "/" '{print $2}') ROT_BACKENDEPS="${ROT_BACKENDEPS} \$(top_builddir)/rotators/${ROTDIR}/libhamlib-${ROTDIR}.la" done @@ -768,7 +768,7 @@ AC_SUBST([ROT_BACKENDEPS]) # otherwise parallel 'make -jn' will fail for be in ${AMP_BACKEND_LIST} ; do - AMPDIR=`echo $be | awk -F "/" '{print $2}'` + AMPDIR=$(echo $be | awk -F "/" '{print $2}') AMP_BACKENDEPS="${AMP_BACKENDEPS} \$(top_builddir)/amplifiers/${AMPDIR}/libhamlib-${AMPDIR}.la" done diff --git a/hamlib.m4 b/hamlib.m4 index fcd495ad1..bf65f1774 100644 --- a/hamlib.m4 +++ b/hamlib.m4 @@ -1,7 +1,7 @@ dnl Configure Paths for Hamlib dnl Cloned from Alsa project http://www.alsa-project.org dnl AM_PATH_HAMLIB([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for libhamlib, and define HAMLIB_LTDL, +dnl Test for libhamlib, and define HAMLIB_LTDL, dnl HAMLIB_CFLAGS and HAMLIB_LIBS as appropriate. dnl enables arguments --with-hamlib-prefix= dnl --with-hamlib-inc-prefix= @@ -51,9 +51,9 @@ fi dnl add the hamlib library HAMLIB_LIBS="$HAMLIB_LIBS -lhamlib -lm -ldl" -LIBS=`echo $LIBS | sed 's/-lm//'` -LIBS=`echo $LIBS | sed 's/-ldl//'` -LIBS=`echo $LIBS | sed 's/ //'` +LIBS=$(echo $LIBS | sed 's/-lm//') +LIBS=$(echo $LIBS | sed 's/-ldl//') +LIBS=$(echo $LIBS | sed 's/ //') #LIBS="$HAMLIB_LIBS $LIBS" AC_MSG_RESULT($HAMLIB_LIBS) @@ -75,8 +75,8 @@ dnl Now that we know that we have the right version, let's see if we have the li if test "x$hamlib_found" = "xyes" ; then ifelse([$2], , :, [$2]) - LIBS=`echo $LIBS | sed 's/-lhamlib//g'` - LIBS=`echo $LIBS | sed 's/ //'` + LIBS=$(echo $LIBS | sed 's/-lhamlib//g') + LIBS=$(echo $LIBS | sed 's/ //') LIBS="-lhamlib $LIBS" fi if test "x$hamlib_found" = "xno" ; then @@ -93,4 +93,3 @@ AC_SUBST(HAMLIB_CFLAGS) AC_SUBST(HAMLIB_LIBS) AC_SUBST(HAMLIB_LTDL) ]) -