secretGeek / ok-bash

.ok folder profiles for bash
MIT License
89 stars 6 forks source link

Availability for scripts might cause problems #27

Closed doekman closed 4 years ago

doekman commented 4 years ago

When using ok-bash within an external script (like awesomecsv, revision 2) there might be a problem.

The script (awesomecsv) can use ok, because it's exported as an bash function with this line:

export -f ok

This line causes some problems, notably in GitHub Desktop when pushing I get an warning /bin/sh: error importing function... I think is caused by ok-bash. I've filed this issue via GitHub Developer Support (there is no public issue tracker for this), but we couldn't really track down the cause.

However, when not exporting the function, the problem seems to go away.

I think the function export would best be removed. As alternative, external tools can source the ok-bash into their own environment with this code (including discovery):

if [[ -r "$_OK__PATH_TO_ME/ok.sh" ]]; then
    . "$_OK__PATH_TO_ME/ok.sh" #and some options
fi

However, it would be nice to have a why for this problem.

For the time being, I've pushed a seperate branch called no-function-export demonstrating the solution. I'll merge it when I've got more information on this.

doekman commented 4 years ago

Fixed with commit 6d141cdfa239348af1d7bc281cb3f804cf950e50

External scripts can import function as demoed in the awesomecsv script.

Not 100% sure if this fixes the GitHub Desktop issue though...