Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm using node-gyp on Linux with and need to use actions to define custom build steps (note sure whether this is a node-gyp issue or a general gyp issue).
The documentation seems to suggest that you should specify the command for the build steps as an array of strings, which must get concatenated together at some point to form the command:
'action': ['python', 'tools/js2c.py', '<@(_outputs)', 'CORE', '<@(core_library_files)'],
As it's Linux, node-gyp is going to generate a makefile for each target in the binding.gyp file, and for actions the custom command will appear in that makefile.
The problem I'm having is that the command needs to contain an = sign to set an environment variable as part of the command, and I need to chain commands with &&, e.g.:
export FOO=BAR && do-something-else --option
If I try to specify that as a gyp actions step, I hit various problems. I tried adding each 'word' in the command as a separate array element.
'action': ['export', 'FOO=BAR', '&&', 'do-something-else', '--option'],
That doesn't work, gyp (or rather the shell the command is passed to) complains that '&&' is not a valid identifier.
Peeking into the generated makefile, the command has been expanded to this, which explains the shell error:
export "FOO=BAR" "&&" do-something-else --option
The quotes have been left around the variable assignment and the &&. It's not clear why. I've tried many variations to stop this from happening to no avail. Anything that contains = or & ends up with quotes left around it, which in most cases renders the command syntax invalid.
Suggestions appreciated.
The reason this happens is that Gyp considers everything after the first word to be an argument to the command given in the first word so it quotes these and other special characters to prevent the shell interpreting them. I do not think there is any way to prevent it which, as you discovered, makes creating a custom command using a pipeline of shell commands well nigh impossible.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.