Atom complains about functions defined in ~/.bash_profile


#1

i cannot figure out this vexing issue and hope to get some enlightenment from the community. I am on OSX using /bin/bash as my shell. as i use atom, it often throws error regarding a custom function i define in my ~/.bash_profile:

Fetching outdated packages and themes failed.Hide output…
/bin/bash: wrsync: line 1: syntax error: unexpected end of file
/bin/bash: error importing function definition for `wrsync’

undefined

and the function in question looks like this (and my bash never complains about it):

# rsync the current folder to remote destination on save
function wrsync() {
  command supervisor -n exit -w . -e '.' -x rsync -- -avzhe ssh . $@ --no-l --exclude=.git/ --exclude=*.pyc --exclude=.DS_Store
}
export -f wrsync

how can i get more information about the error? it seems this error also gets triggered by python-autocomplete somehow and interrupts its functionality. it has been very frustrating to deal with. Any suggestion would be appreciated!


#2

I am getting essentially the same. Necessary to say, it’s autocomplete-python, who’s complaining about functions defined in ~/.bash_profile


#3

i actually thinks it is more basic to how Atom calls the shell, for example, i also saw this error triggered by script. Here is a solution i found: https://github.com/platformio/platformio-atom-ide-terminal/issues/120#issuecomment-274870224

basically, you want to launch atom from terminal instead of your macOS launcher. this fixes the problem for me. I am not familiar with macOS application’s launchers but there should be a simple fix.


#4

I actually knew this once, but subsequently forgot it, thank you for reminding me! This is a workaround to those errors.


#5

One thing you might try: change --exclude=*.pyc to --exclude='*.pyc'. If there are any .pyc files in the directory when you invoke that command, the shell will expand *.pyc to a list of those files, which will probably not work if there’s more than one .pyc file. The quotes keep this from happening.


#6

Oh, and $@ should be "$@" to correctly handle spaces in input parameters.


#7

thanks for the suggestions but my .bash_profile actually works fine as is. In fact, i tried commenting/removing all my custom functions to no avail. i think it has something to do with the difference in launching via an initialized shell vs launching via macOS application launcher.