Comments (19)
Interesting. What does process.env.TERM
end up being when you see the ANSI codes and which shell and OS is this on?
from fix-path.
- TERM=xterm-256color
- shell: bash
from fix-path.
Pushed sindresorhus/shell-path@1703975, can you give that one a try?
from fix-path.
Note: I don't understand what \u001b(B\u001b[m
does, but I guess it won't hurt if we strip it. Maybe @Qix- has some insight?
from fix-path.
Note: I don't understand what \u001b(B\u001b[m does
Neither do I :).
Will try it tomorrow, just closed my laptop but guess it'll work as strip-ansi
was the hotfix I used in my code.
from fix-path.
Couldn't we just disable colors by for example changing echo "$PATH"
to something like TERM=dumb; echo "$PATH"
?
from fix-path.
The less dependencies, the better. Will try it out tomorrow!
from fix-path.
Couldn't resist, had to know :).
Tried this:
function pathFromSudoSync() {
try {
return childProcess.execSync('TERM=dumb; sudo -Hiu ' + user + ' echo "$PATH"', opts).trim();
} catch (err) {
// may fail with 'sudo: must be setuid root'
return '';
}
}
But still returns a string with color codes. This is the .bash_prompt I use btw. Maybe this offers some more insights.
from fix-path.
Not sure what (B
is but [m
is analogous to [0m
. I don't think it's standard.
from fix-path.
Pretty sure that \u001b(B\u001b[m
has nothing to do with color at least.
$ node -e 'console.log("\u001b(B\u001b[mHi!")'
Hi!
from fix-path.
[0m
(or [m
) means reset render. \u001b(B
seems strange. I'll have to research. I can take a look later; my attention is on the mass shooting right now, heh.
from fix-path.
I did some more investigation in the dot-file. It's actually this line that is the cause of all this.
from fix-path.
Googling the first three bytes 0x1B 0x28 0x42
tells me it's some kind of japanese escape sequence?
http://www.sxemacs.org/docs/internals/JIS7.html
Escape sequence ASCII equivalent Meaning
--------------- ---------------- -------
0x1B 0x28 0x4A ESC ( J invoke Japanese-JISX0201-Roman
0x1B 0x28 0x49 ESC ( I invoke Japanese-JISX0201-Kana
0x1B 0x24 0x42 ESC $ B invoke Japanese-JISX0208
0x1B 0x28 0x42 ESC ( B invoke Printing-ASCII
from fix-path.
Confirming it's the output of tput sgr0
, which appears to be a color reset that also seems to reset japanese terminals to regular ASCII mode. I still think my fix is worth to keep, as TERM=dumb
does probably not take care of \u001b(B
.
> child_process.execSync('tput sgr0', {encoding: 'utf8'})
'\u001b(B\u001b[m'
from fix-path.
TERM=dumb
does remove both sequences for me on both OSX and Linux. Now if only I could get this execSync
to work 😕
> child_process.execSync("tput sgr0", {encoding: 'utf8', env: process.env})
'\u001b(B\u001b[m'
> process.env.TERM = 'dumb'
'dumb'
> child_process.execSync("tput sgr0", {encoding: 'utf8', env: process.env})
Error: Command failed: tput sgr0
from fix-path.
When executing that I noticed the shell of child_process
is sh
. Tried changing that to bash
but didn't seem to work either.
from fix-path.
That's not uncommon, unless you specifically invoke the shell of your choice, you're going to get /bin/sh
.
from fix-path.
Won't matter in which shell that sudo
executes. The -i
option does "run the shell specified by the target user's password database entry as a login shell".
from fix-path.
Just realized I never published the strip-ansi
workaround. Done now. Keeping this issue open as I'd still like to find a better fix. Open to additional suggestions.
from fix-path.
Related Issues (14)
- Ubuntu Linux Also ? HOT 4
- Fix-path breaks quit from dock in packaged electron app on OSX HOT 4
- Webpack warning: Module not found: Error: Can't resolve 'spawn-sync'
- Module not found: Can't resolve 'node:os' HOT 4
- ES Module import error HOT 2
- Must use import to load ES Module HOT 1
- how to use with require() ? HOT 4
- Get $PATH from the real shell HOT 1
- Different PATH with fixPath compared to $PATH in terminal? HOT 17
- Path not being fixed HOT 33
- Unexpected token error HOT 7
- No effect in PATH? HOT 2
- Implement $PATH detection using `/usr/libexec/path_helper` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fix-path.