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

make lpstat output LANG aware in MacOS #3

Merged
merged 2 commits into from
Dec 24, 2024
Merged

Conversation

ice6
Copy link
Contributor

@ice6 ice6 commented Dec 17, 2024

so that the script can work in non-english user's mac machine.

ice6 added 2 commits December 17, 2024 19:37
sets the environment variable SOFTWARE to an empty value. so the `lpstat` can output in right `LANG` as you set.
sets the environment variable SOFTWARE to an empty value
@sapireli
Copy link
Owner

Thank you so much for the submission, i already implemented this in the code where you see:
export LANG=C export LC_ALL=C

Glad it worked! Happy new year.

@sapireli sapireli closed this Dec 22, 2024
@ice6
Copy link
Contributor Author

ice6 commented Dec 24, 2024

hi @sapireli happy new year!

then, you have to add this line to your code: export SOFTWARE=.

see the detail here:

#2

I am sorry that I closed the issue too early .

@sapireli
Copy link
Owner

sapireli commented Dec 24, 2024

@ice6 happy new year to you and yours as well!

In a bash script, the line:

export SOFTWARE=.

does the following:
1. Sets an environment variable:
• The export command marks the variable SOFTWARE for export to child processes of the shell.
• This means any subprocess (like another script or program) spawned from this shell will have access to the SOFTWARE variable.
2. Assigns a value:
• SOFTWARE=. assigns the value . (the current directory) to the SOFTWARE variable.
• The dot (.) is a shorthand for the current working directory in Linux/Unix systems.

In our Use Case: it doesn’t do anything as it is not used in the script. Two lines that follow in the updated version is what forces English for the all the subprocesses which we spawn and that’s what fixed the issue.

@ice6
Copy link
Contributor Author

ice6 commented Dec 24, 2024

@sapireli I hope this picture can make the idea clear.

企业微信截图_17350277062294

without the export SOFTWARE=, in my wired machine, it still outputs chinese.

@sapireli
Copy link
Owner

sapireli commented Dec 24, 2024

Thank you 🙏. Let me examine this in a test environment. I don’t fully understand why passing a variable changes anything

@sapireli sapireli reopened this Dec 24, 2024
@sapireli sapireli merged commit eceb174 into sapireli:main Dec 24, 2024
@sapireli
Copy link
Owner

sapireli commented Dec 24, 2024

This works well. Great find thank you so much. Happy holidays and happy new year 🙏 @ice6

@ice6
Copy link
Contributor Author

ice6 commented Dec 25, 2024

@sapireli happy holidays. 🤗

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.

2 participants