PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, December 7, 2022

[FIXED] What does this command do in VSCode's CLI launch script?

 December 07, 2022     bash, syntax, variable-assignment     No comments   

Issue

In VSCode's (MacOS) launch script, we can find the following lines:

CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"

What is going on with the last line (which actually goes and executes the CLI)? Why is there a 1 in front of the command?


Solution

When you put a variable assignment at the beginning of a shell command, it sets that environment variable temporarily while running the command. So the last line is effectively equivalent to:

(
    export ELECTRON_RUN_AS_NODE=1
    "$ELECTRON" "$CLI" "$@"
)

The parentheses put the commands in a subshell, so the variable assignment doesn't persist.



Answered By - Barmar
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing