This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cs:usable_windows [2020/02/12 09:27] paolo_bolzoni I love candies |
cs:usable_windows [2020/04/01 05:01] (current) paolo_bolzoni little touch up in winpty |
||
---|---|---|---|
Line 20: | Line 20: | ||
- | ==== Admin access === | + | === Msys2 path mangling === |
+ | |||
+ | Since Windows expects paths like ''c:/Users/Sato/'' and Unix expects paths like ''/home/Sato'' the Msys2 shell does path mangling so that windows programs will find what is expected. | ||
+ | |||
+ | For example, one types: | ||
+ | |||
+ | ./prg.exe / /c/Users/Sato/Music/ | ||
+ | |||
+ | and the passed arguments (''argv'' in C parlance) are: | ||
+ | |||
+ | C:\msys64\home\Sato\prg.exe | ||
+ | C:/msys64/ | ||
+ | C:/Users/Sato/Music/ | ||
+ | |||
+ | Normally this is fine, but seldom it breaks programs. To disable it one needs to setup an environment variable: ''MSYS2_ARG_CONV_EXCL'' ([[https://github.com/msys2/msys2/wiki/Porting#filesystem-namespaces|Documentation]]). | ||
+ | |||
+ | == Docker == | ||
+ | |||
+ | A common example is docker for windows. One probably wants an alias in their ''~/.bashrc''. | ||
+ | |||
+ | alias docker='MSYS2_ARG_CONV_EXCL="*" docker' | ||
+ | |||
+ | So that Msys2 won't mangle any path. | ||
+ | |||
+ | === TTY-sensible programs === | ||
+ | |||
+ | Few programs, like __nodejs__, have problems using Msys2. When you execute them the console seems to hang. It happens because they expect the stdout do be a TTY, in other words stdout must follow the terminal interface protocol. | ||
+ | |||
+ | The Mysys2 shell does not: | ||
+ | |||
+ | $ node -p -e 'Boolean(process.stdout.isTTY)' | ||
+ | false | ||
+ | |||
+ | Fortunately there is a solution: the program **winpty** | ||
+ | |||
+ | $ winpty node -p -e "Boolean(process.stdout.isTTY)" | ||
+ | true | ||
+ | |||
+ | Let us see in action: | ||
+ | |||
+ | $ node | ||
+ | |||
+ | Nothing happens, until you press CTRL-C stopping it. | ||
+ | |||
+ | $ winpty node | ||
+ | Welcome to Node.js v13.11.0. | ||
+ | Type ".help" for more information. | ||
+ | > | ||
+ | |||
+ | Much better! **winpty** can be installed with pacman. | ||
+ | ==== Admin access ==== | ||
Seldom one needs to execute a command as superuser. | Seldom one needs to execute a command as superuser. | ||
Line 35: | Line 85: | ||
[[https://www.autoitscript.com/|AutoIt v3 is a freeware BASIC-like scripting language.]] | [[https://www.autoitscript.com/|AutoIt v3 is a freeware BASIC-like scripting language.]] | ||
- | Scripting language able also of automating the Windows GUI that compiles in self contained .exe files. | + | Scripting language able of automating the Windows GUI and that compiles in self-contained .exe files. |
+ | |||
+ | |||
+ | ==== Clipboard from the command line ==== | ||
+ | |||
+ | Windows now have ''clip'' a program to read content from stdin and write in the clipboard. However the help message does not tell anything about the encoding ''clip'' expects. The encoding is ''utf-16le'', so one needs to use: | ||
+ | |||
+ | iconv -f utf-8 -t utf-16le | clip | ||
+ | |||
+ | Also it can be useful to consider [[http://www.stahlworks.com/dev/swiss-file-knife.html|sfk.exe]] to be able to read //from// the clipboard (among other things ''sfk.exe'' does). |