0

I'm getting lots of errors on FreeBSD 10.1 amd64 because I use Bash and my .bash_profile exports some functions. When I attempt to run a test script on FreeBSD, it results in:

$ ./cryptest.sh 
bash: Skipping importing function definition for `sh_perms': --import-functions required.
bash: Skipping importing function definition for `sh_gclean': --import-functions required.
...
make: environment corrupt; missing value for BASH_FUNC_sh_clean
make: environment corrupt; missing value for BASH_FUNC_sh_clean
make: environment corrupt; missing value for BASH_FUNC_sh_clean
...

I'm not finding much information, but I did find mention of IMPORTFUNCTIONS in the FreeBSD Bash page:

The default can also be changed in the port by selecting the IMPORTFUNCTIONS option ...

I added the following to .bash_profile, logged off, logged back on (and even source'd .bash_profile), but the issue persists:

IS_FREEBSD=$(uname -s | grep -i -c freebsd)

if [[ ("$IS_FREEBSD" -ne "0") ]]; then
    export IMPORTFUNCTIONS=y
fi

I know the CVE FreeBSD is remediating, but I don't really care about it. I'm not a FreeBSD admin, and I cringe thinking I'm going to need a week trying to fix this by rummaging for information. I only power up and log onto this machine a few times a year to test some software, so I need the machine to work.

How do fix the shell so it works as expected?


Here's an example of a function; and there's not much to it. It allows me to quickly reset a branch on a Git repo and update it in one command. I use them because Git has a penchant for taking simple workflows, and complicating it or making it difficult to impossible (you should see how difficult it is to delete a dev-branch).

function sh_gpull {
    if [[ (-z $(git rev-parse HEAD 2>/dev/null)) ]]; then
        echo "$PWD is not a Git repository"
        [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
    fi

    echo "Branch:" $(git rev-parse --abbrev-ref HEAD 2>/dev/null)
    git reset --hard HEAD 2>/dev/null
    git pull

    [[ "$0" = "$BASH_SOURCE" ]] && exit 0 || return 0
}

...
export -f sh_gpull ...
  • This is actually nothing to do with FreeBSD. You would be experiencing this on any system, from OpenBSD to CloudLinux, where you had a build of the Bourne Again shell whose builder had decided to turn off function import from environment variables. – JdeBP Sep 10 '16 at 10:59
  • @JdeBP - I test on every OS I can get my hands on, including OpenBSD, FreeBSD, NetBSD, Linux, OS X, Unix, Solaris, Red Hat, Fedora, Debian, Ubuntu, Linaro, Arch Linux, iOS, Android (and the Windows). There's about 90 platforms in all when versions are taken into account. I use Bash on all of them, and FreeBSD is the only one that has the trouble. – user56041 Sep 10 '16 at 11:09
  • The FreeBSD change came from NetBSD where it was turned off too, and made it thence to places such as CloudLinux and OpenSUSE. It was written by NetBSD developer Christos Zoulas. Any build of the Bourne Again shell that M. Zoulas' fix made it to, you will see this behaviour. It is nothing to do with FreeBSD. – JdeBP Sep 10 '16 at 14:19
  • @JdeBP - I test under both OpenSUS and NetBSD. Neither witness the problem. I don't use CloudLinux, so I don't know if the issue is present under it. The problem only surfaces on FreeBSD. I'm sorry if it offends you, but that's the way it is. – user56041 Sep 10 '16 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy