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

Inherited environment variables don’t always get passed down correctly #72

Open
Rinzwind opened this issue Jul 25, 2022 · 0 comments
Open

Comments

@Rinzwind
Copy link

Rinzwind commented Jul 25, 2022

The Bash script given below gives a few examples in which OSSUnixSubprocess doesn’t pass down inherited environment variables as expected, the output is:

$ ./test.sh 
OK (\x41\x42\x43):
0000000 41 42 43                                       
0000000 41 42 43                                       

Output does not match (\x09\x31\x09\x32\x09):
0000000 09 31 09 32 09                                 
0000000 31 09 32                                       

Output does not match (\x46\x72\x61\x6E\xC3\xA7\x61\x69\x73):
0000000 46 72 61 6e c3 a7 61 69 73                     
0000000 46 72 61 6e e7 61 69 73                        

Error in Pharo (\x46\x72\x61\x6E\xE7\x61\x69\x73):
0000000 46 72 61 6e e7 61 69 73                        
ZnInvalidUTF8: Illegal continuation byte for utf-8 encoding

Error in Pharo (\xF0\x9F\x92\xA3):
0000000 f0 9f 92 a3                                    
Instance of WideString did not understand #tfPointerAddress

The script ‘test.sh’ (you will probably need to modify ‘pharovm’ and ‘pharoimage’):

#!/bin/bash

pharovm=~/'Documents/Pharo/vms/110-x64/Pharo.app/Contents/MacOS/Pharo'
pharoimage=~/'Documents/Pharo/images/Pharo 11.0 - 64bit (development version, latest)/Pharo 11.0 - 64bit (development version, latest).image'
script="
	[
		Metacello new
			baseline: 'OSSubprocess';
			repository: 'github://pharo-contributions/OSSubprocess:master/repository';
			load
	] on: MetacelloNotification , NewUndeclaredWarning do: [ :notification |
		notification resume ].
	(Smalltalk at: #OSSUnixSubprocess) new
		shell: '/bin/bash' command: 'echo -n \"\$TEST\" | hexdump';
		runAndWait.
	nil"

run() {
	printf '%s\n' "$1 ($2):"
	export TEST="$(printf %b "$2")"
	/bin/bash -c 'echo -n "$TEST" | hexdump' | head -n 1
	"${pharovm}" --headless "${pharoimage}" eval "${script}" 2>&1 | head -n 1
	tput sgr0
	printf '\n'
}

run 'OK' '\x41\x42\x43'
run 'Output does not match' '\x09\x31\x09\x32\x09'
run 'Output does not match' '\x46\x72\x61\x6E\xC3\xA7\x61\x69\x73'
run 'Error in Pharo' '\x46\x72\x61\x6E\xE7\x61\x69\x73'
run 'Error in Pharo' '\xF0\x9F\x92\xA3'
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

No branches or pull requests

1 participant