Skip to content

No alias usable in check command definitions #40

@DavidPL1

Description

@DavidPL1

Check shells are spawned via subprocess with the executable path set to the configured shell path (/bin/bash by default) and before running the specified command, the custom environment is loaded, if one is given. If the custom environment defines aliases they are not going to work when used in the check command, because subprocess spawns a non-interactive shell, which does not feature usage of aliases.

I tried changing the subprocess call to spawn an interactive shell and providing a command afterwards like so:

commands = '''
 %s
 %s
 ''' % (shell_init, check)

 p = Popen(
      [config.SHELL_EXECUTABLE_PATH, "-i"],
      stdin=PIPE,
      stdout=PIPE,
      stderr=PIPE
 )

 out, err = p.communicate(commands)

This seemed to be working for /bin/bash, but when i tested it with /bin/zsh the interactive shell took over the terminal executing the server and hat to be closed by hand.

This approach feels a bit hacky anyway, so I discarded it. Another way could be to create new tmux windows dedicated to check execution, however it comes with the overhead of managing those windows (spawn and despawn for each check or keep a number of "check-executors") and parsing stdout and stderr. Since at this moment I don't think this overhead is feasible, I decided to keep it the way it is for now.

If you have any ideas feel free to comment and contribute

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions