find wont use .bashrc alias

Bug #366665 reported by Fernando Miguel on 2009-04-25
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
findutils
New
Undecided
Unassigned
findutils (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: findutils

i created this alias:
alias mp3gainB='mp3gain -r -k -t -p -s r'
then tried to run
$ find -type f -name "*.mp3" -exec mp3gainB {} \;
but it failed
running
$ find -type f -name "*.mp3" -exec mp3gain -r -k -t -p -s r {} \;
works as expected

ProblemType: Bug
Architecture: amd64
Dependencies:
 libgcc1 1:4.3.3-5ubuntu4
 gcc-4.3-base 4.3.3-5ubuntu4
 findutils 4.4.0-2ubuntu4
 libc6 2.9-4ubuntu6
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: nvidia
Package: findutils 4.4.0-2ubuntu4
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: findutils
Uname: Linux 2.6.28-12-generic x86_64

Stefan Wagner (wagner-stefan) wrote :

The -exec param of find is executed by find, not by the bash, and find doesn't look into your aliases. This is expected behaviour. Find won't neither execute bash functions. And it does not allow redirection like such:

<code>
$ find -exec ls {} > /dev/null \;
<code>

You have to invoke bash as a login shell (-l) and set the shell option "expand aliases". Read "man bash", especially section ALIASES, for further insights.

<code>
$ find -type f -name "*.mp3" -exec bash -l -O expand_aliases -c "mp3gainB {}" ";"
</code>

Stefan Wagner (wagner-stefan) wrote :

P.S.: Sorry about the failing code-tags, and the missing explanation of -c parameter:

-c tells the bash, that it shall execute the following commands.

The linebreak was unintendet.

find -type f -name "*.mp3" -exec bash -l -O expand_aliases -c "mp3gainB {}" ";"

Stefan Wagner (wagner-stefan) wrote :

As described in the comment below, this is not a bug, but intended behaviour of find. It can be avoided by the right parameter settings.

 I suggest this Bug is invalid.

Changed in findutils (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers