Skip to content

Conversation

@juergenhoetzel
Copy link
Contributor

Fixes issues on BSDs where the default shell is tcsh and "export="
syntax is invalid. Refs #59.

Fixes issues on BSDs where the default shell is tcsh and "export="
syntax is invalid. Refs pressly#59.
@VojtechVitek
Copy link
Collaborator

VojtechVitek commented May 4, 2016

Please, do not merge. I need to test this properly. Seems like script depending on Bash doesn't work properly anymore -- and also, seems like Env Vars are not exported properly.

@juergenhoetzel juergenhoetzel changed the title Use posix shell explicitly for remote commands Use posix shell explicitly for remote commands (WIP) May 5, 2016
@juergenhoetzel
Copy link
Contributor Author

Seems like script depending on Bash doesn't work properly anymore -- and also, seems like Env Vars are not exported properly.

Exporting works for me. But I can confirm the script issue:

Unmatched '.

Seems to be a quoting issue

@eduardonunesp
Copy link
Contributor

eduardonunesp commented May 5, 2016

It is something that must be necessary in order to Sup works fine, the /bin/sh shell, unfortunately Sup must require the existence of /bin/sh in the remote host and the internal commands at Sup need to "force" the /bin/sh style.

@eduardonunesp
Copy link
Contributor

@juergenhoetzel Could you please show us that script, or some script that fails like your script.

@VojtechVitek
Copy link
Collaborator

Given Supfile

commands:
  build:
    script: ./build.sh

and ./build.sh:

#!/bin/bash -eu

[[ "hello" != "there" ]] && exit 0 || exit 1 

We need to make sure this is run under Bash, since there's #!/bin/bash at the very beginning of the file. Otherwise, we're gonna break things for many users. Actually, this bite me yesterday pretty bad, since ENV VARs didn't work properly and coincidently, this managed to kill one of my servers.

I don't want to implement parser for the script's first line on a Golang side. We need to figure out a native solution in /bin/sh itself.

@VojtechVitek
Copy link
Collaborator

@juergenhoetzel btw: does your FreeBSD have /bin/bash natively? I'm inclined to switch to Bash by default for now, if available everywhere.

@VojtechVitek VojtechVitek changed the title Use posix shell explicitly for remote commands (WIP) [WIP] Use posix shell explicitly for remote commands May 5, 2016
@eduardonunesp
Copy link
Contributor

A native solution to check which interpreter is using, is echo $0

@juergenhoetzel
Copy link
Contributor Author

@juergenhoetzel btw: does your FreeBSD have /bin/bash natively? I'm inclined to switch to Bash by default for now, if available everywhere.

Bash is not part of the base system. It has to be installed from ports: /usr/local/bin/bash
A portable way to invoke bash would be:

#!/usr/bin/env bash

@juergenhoetzel
Copy link
Contributor Author

and ./build.sh:

#!/bin/bash -eu

[[ "hello" != "there" ]] && exit 0 || exit 1

As far as I can see the shebang is not used in the sup implementation. It's just a comment, because its send as shell command and is not executed as a script:

@VojtechVitek
Copy link
Collaborator

@juergenhoetzel correct, the idea is to let the remote shells parse the shebangs, since we want to use /bin/sh by default. Thus, this /bin/sh should invoke another bash, if it sees #!/bin/bash shebank. I'm not a huge fun of temp files, but that might be an option.

@juergenhoetzel
Copy link
Contributor Author

I'm not a huge fun of temp files, but that might be an option.

This was exactly what i was thinking about. Have you considered using sftp subsystem for file transfer?
https://github.com/pkg/sftp instead of piping?

@VojtechVitek
Copy link
Collaborator

Closing in favor of #77.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants