Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 680932 - devmanual Makefile uses bashisms
Summary: devmanual Makefile uses bashisms
Status: RESOLVED FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Devmanual (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Devmanual Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2019-03-19 13:23 UTC by Michael Orlitzky
Modified: 2019-03-19 17:11 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-Makefile-remove-BASH-specific-type-p-and-idioms.patch (0001-Makefile-remove-BASH-specific-type-p-and-idioms.patch,2.05 KB, patch)
2019-03-19 16:45 UTC, Michael Orlitzky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2019-03-19 13:23:25 UTC
The devmanual's Makefile runs things like

  prereq:
      @type -p convert &>/dev/null ...

which works in bash:

  $ type -p convert
  /usr/bin/convert

but not in e.g. dash:

  $ dash
  $ type -p convert
  -p: not found
  convert is /usr/bin/convert

A workaround for this is to set

  SHELL = /bin/bash

at the top of the Makefile, but it would be better to avoid the bashisms entirely.
Comment 1 Michael Orlitzky gentoo-dev 2019-03-19 14:13:34 UTC
Since the output from "type" is never used, it looks like the "-p" can simply be dropped without hurting anything.
Comment 2 Michael Orlitzky gentoo-dev 2019-03-19 16:45:00 UTC
Created attachment 569780 [details, diff]
0001-Makefile-remove-BASH-specific-type-p-and-idioms.patch

This fixes the "type -p" thing, and also the "&>" shortcut that is bash-specific.  The existing check is a little bit more broken than I originally thought, since the "&>" tricks Dash into returning success even when e.g. "convert" is not present. Of course the build just fails later on... but this patch should bring bash/dash to parity.
Comment 3 Larry the Git Cow gentoo-dev 2019-03-19 17:11:15 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=ad73851922df05d91b9be52f41529014c3482113

commit ad73851922df05d91b9be52f41529014c3482113
Author:     Michael Orlitzky <mjo@gentoo.org>
AuthorDate: 2019-03-19 16:01:18 +0000
Commit:     Brian Evans <grknight@gentoo.org>
CommitDate: 2019-03-19 16:57:54 +0000

    Makefile: remove BASH-specific "type -p" and "&>" idioms.
    
    The Makefile uses two "type -p" commands to determine if the "convert"
    and "xsltproc" commands are present. The "type" command itself is
    defined in POSIX,
    
      http://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html
    
    but the additional "-p" flag is BASH-specific. This can lead to
    unexpected behavior when the /bin/sh symlink that the Makefile uses by
    default points to a non-BASH shell:
    
      $ dash
      $ type -p convert
      -p: not found
      convert is /usr/bin/convert
    
    By chance, this is ultimately not fatal, but does cause the default
    target to output some confusing messages. And in fact the output from
    the "type -p" command is never used, which means that "type" itself
    should suffice, in any shell. Thus this commit drops the two "-p"
    arguments to "type".
    
    The same two "type" commands attempt to redirect both stdout and
    stderr to /dev/null using the BASH "&>" shortcut. This commit replaces
    it with the standard, but more verbose incantation ">/dev/null 2>&1"
    that is portable to other shells.
    
    Closes: https://bugs.gentoo.org/680932
    Signed-off-by: Michael Orlitzky <mjo@gentoo.org>
    Signed-off-by: Brian Evans <grknight@gentoo.org>

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)