Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 488230 - media-sound/split2flac - bashisms result in incorrect runtime detection of available applications (e.g., flac vs. flake)
Summary: media-sound/split2flac - bashisms result in incorrect runtime detection of av...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Nikoli
URL: https://github.com/ftrvxmtrx/split2fl...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-16 14:25 UTC by Marc Joliet
Modified: 2013-10-21 07:56 UTC (History)
3 users (show)

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


Attachments
Fixes output redirection to work with dash (split2flac_fix_redirect.patch,658 bytes, patch)
2013-10-16 14:27 UTC, Marc Joliet
Details | Diff
Fixes output redirection to work with dash (v2) (split2flac_fix_redirect.patch,674 bytes, patch)
2013-10-17 10:19 UTC, Marc Joliet
Details | Diff
ebuild (split2flac-113_p20131017.ebuild,1.34 KB, text/plain)
2013-10-17 16:08 UTC, Nikoli
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Joliet 2013-10-16 14:25:48 UTC
media-sound/split2flac is POSIX shell script, which however contains two counts of what to my surprise turned out to be a bashism: the &> redirection operator. This breaks the runtime detection of applications via "which"; in my case split2flac.sh was trying to use flake, which I don't have installed.

I patched it on my system by replacing the occurrences of "&>/dev/null" with "2>&- >&-", which effectively does the same by closing stdout and stderr (see attached patch).

Reproducible: Always

Steps to Reproduce:
1. Run split2flac.sh (with, e.g., flac but not flake installed, and using dash as the /bin/sh implementation)
Actual Results:  
split2flac.sh fails because it cannot find flake

Expected Results:  
split2flac.sh succesfully splits and encodes the WAV file with flac

$ emerge --info split2flac
Portage 2.2.1 (default/linux/amd64/13.0, gcc-4.7.3, glibc-2.15-r3, 3.10.7-gentoo-r1 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.10.7-gentoo-r1-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_4200+-with-gentoo-2.2
KiB Mem:     4047300 total,    646788 free
KiB Swap:    4194300 total,   4067188 free
Timestamp of tree: Tue, 15 Oct 2013 20:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.1
app-shells/bash:          4.2_p45
dev-lang/python:          2.7.5-r2, 3.2.5-r2
dev-util/cmake:           2.8.10.2-r2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.1
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo science sunrise ladi proaudio pd-overlay mjoliet
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --quiet-build=y --nospinner"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync metadata-transfer news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://de-mirror.org/distro/gentoo/ ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ ftp://mirror.muntinternet.net/pub/gentoo/"
LANG="de_DE.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-s -j3"
PKGDIR="/usr/portage/packages"
PORTAGE_COMPRESS="xz"
PORTAGE_COMPRESS_FLAGS="-9"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/science /usr/local/portage/layman/sunrise /usr/local/portage/layman/ladi /usr/local/portage/layman/pro-audio /usr/local/portage/layman/pd-overlay /usr/local/portage/marcec"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acl alsa amd64 avahi berkdb branding bzip2 cairo caps cdinstall cjk cli consolekit cracklib crypt css cups cxx dbus dga djvu dri dssi dts dvd encode exif fbcon ffmpeg fftw fish-completion flac fortran ftp fuse gdbm gif gmp gnuplot gnutls gtk iconv idn imlib inotify ipv6 jack jackmidi jpeg jpeg2k kipi ladspa lapack lash latex lcms libnotify libsamplerate logrotate lzma mad mjpeg mmx mmxext mng modplug modules mp3 mp4 mpeg mudflap multilib musepack musicbrainz ncurses nfs nls nptl ntp offensive ogg openexr opengl openmp opus osc pam pango pcre pdf plotutils png policykit pulseaudio qt4 quicktime rar readline rtsp samba sasl session sid slang smp sndfile speex spell sse sse2 sse3 ssl startup-notification svg sysfs taglib tcpd theora threads tiff timidity truetype unicode usb vaapi vdpau vim-syntax vorbis vpx webkit wma x264 xattr xcb xcomposite xface xft xml xmp xpm xscreensaver xv xvid zeroconf zlib zsh-completion" ABI_X86="64" ALSA_CARDS="ice1724 hda-intel usb-audio" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_US en en_GB de" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="x86_64" QEMU_USER_TARGETS="x86_64" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="radeon vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

media-sound/split2flac-0.1_pre20111110-r2 was built with the following:
USE="imagemagick mp3 mp4 (multilib) ogg replaygain -enca -flake -mac -wavpack" ABI_X86="64"
Comment 1 Marc Joliet 2013-10-16 14:27:15 UTC
Created attachment 361040 [details, diff]
Fixes output redirection to work with dash
Comment 2 Martin Väth 2013-10-16 18:53:56 UTC
I suggest to use ">/dev/null 2>&1" instead of closing - the latter might not work as expected on some systems.

Moreover, when you are at it, I suggest to replace "which" by "command -v", since only the latter is POSIX.
Comment 3 Marc Joliet 2013-10-16 20:32:11 UTC
(In reply to Martin Väth from comment #2)
> I suggest to use ">/dev/null 2>&1" instead of closing - the latter might not
> work as expected on some systems.

That's the first thing I tried. And it didn't work, because I see now that I got the order of the two redirects wrong (I guess I wasn't aware that it was important). So I'll change the patch to do that.

> Moreover, when you are at it, I suggest to replace "which" by "command -v",
> since only the latter is POSIX.

Hmm, sure, I can do that, although really I just wanted it to work with dash :) .
Comment 4 Marc Joliet 2013-10-17 10:19:38 UTC
Created attachment 361104 [details, diff]
Fixes output redirection to work with dash (v2)

OK, I implemented the suggested changes. It turns out that "command -v" does not output to stderr, so "command -v some_command >/dev/null" is enough.
Comment 5 Marc Joliet 2013-10-17 10:47:00 UTC
Just a small update: I sent a pull request upstream: https://github.com/ftrvxmtrx/split2flac/pull/8.
Comment 6 Marc Joliet 2013-10-17 10:53:11 UTC
(In reply to Marc Joliet from comment #5)
> Just a small update: I sent a pull request upstream:
> https://github.com/ftrvxmtrx/split2flac/pull/8.

Wow, merged already! That was quick :) .
Comment 7 Nikoli 2013-10-17 14:54:53 UTC
Thank you for report and patch, seems we need to add new snapshot to tree :)
Comment 8 Nikoli 2013-10-17 16:08:59 UTC
Created attachment 361138 [details]
ebuild

Updated ebuild, please commit it as split2flac-113_p20131017.ebuild and split2flac-9999.ebuild
Comment 9 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2013-10-21 07:56:55 UTC
+  21 Oct 2013; Tom Wijsman <TomWij@gentoo.org> +split2flac-113_p20131017.ebuild,
+  split2flac-9999.ebuild:
+  Version bump to 113_p20131017; fixes bug #488230, reported by Marc Joliet and
+  proxied commit for Nikoli.

Thank you for your contribution.