Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ynh_print_OFF when set -x is used in other helpers #733

Merged
merged 1 commit into from Jun 7, 2019

Conversation

Projects
None yet
3 participants
@maniackcrudelis
Copy link
Contributor

commented Jun 1, 2019

The problem

As reported by @Josue-T, ynh_print_OFF doesn't work when used before a helper using getopts, because the helper getopts use set -x.

Solution

Redirect BASH_XTRACEFD, the file descriptor for xtrace, to /dev/null to get rid of the trace.
Then redirect back to stdout.

PR Status

Tested on leed.

How to test

...

Validation

  • Principle agreement 0/2 :
  • Quick review 0/1 :
  • Simple test 0/1 :
  • Deep review 0/1 :

@YunoHost/apps

@alexAubin
Copy link
Member

left a comment

Uh wokay, looks like black magic but trusting you I guess ? :D

@alexAubin alexAubin added this to the 3.6.x milestone Jun 3, 2019

@maniackcrudelis

This comment has been minimized.

Copy link
Contributor Author

commented Jun 3, 2019

;)
Not really black magic, just using BASH_XTRACEFD, which contains the file descriptor (usually 7) and redirect it to /dev/null instead of stdout.
You can see that when using --debug, the command line contains BASH_XTRACEFD=7 [...] 7>&1'

@kay0u

This comment has been minimized.

Copy link
Contributor

commented Jun 3, 2019

cmd = 'BASH_XTRACEFD=7 /bin/bash -x "{script}" {args} 7>&1'

@alexAubin alexAubin merged commit e935263 into stretch-unstable Jun 7, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.