‘git log’ output encoding issues in Windows 10 CLI terminal

Okay, I experimented a bit and found out that Windows Git commands actually need UNIX variables like LC_ALL in order to display Polish (or other UTF-8 characters) correctly. Just try this command: set LC_ALL=C.UTF-8 Then enjoy the result. Here is what happened on my console (font “Consolas”, no chcp necessary): Update: Well, in order for … Read more

How to handle a ctrl-break signal in a command line interface

OK – this is working for me on Windows & is portable – notice the #ifdef SIGBREAK – this isn’t a standard signal. #include <csignal> #include <iostream> #include <ostream> #include <string> using namespace std; namespace { volatile sig_atomic_t quit; void signal_handler(int sig) { signal(sig, signal_handler); quit = 1; } } int main() { signal(SIGINT, signal_handler); … Read more

What will give me something like ruby readline with a default value?

What you are asking is possible with Readline. There’s a callback where you can get control after the prompt is displayed and insert some text into the read buffer. This worked for me: Readline.pre_input_hook = -> do Readline.insert_text “hello.txt” Readline.redisplay # Remove the hook right away. Readline.pre_input_hook = nil end input = Readline.readline(“Filename: “, false) … Read more

How to run commands via NodeJS child process?

Sending a newline \n will exectue the command. .end() will exit the shell. I modified the example to work with bash as I’m on osx. var terminal = require(‘child_process’).spawn(‘bash’); terminal.stdout.on(‘data’, function (data) { console.log(‘stdout: ‘ + data); }); terminal.on(‘exit’, function (code) { console.log(‘child process exited with code ‘ + code); }); setTimeout(function() { console.log(‘Sending stdin … Read more

How to launch an EDITOR (e. g. vim) from a python script?

Calling up $EDITOR is easy. I’ve written this kind of code to call up editor: import sys, tempfile, os from subprocess import call EDITOR = os.environ.get(‘EDITOR’, ‘vim’) # that easy! initial_message=”” # if you want to set up the file somehow with tempfile.NamedTemporaryFile(suffix=”.tmp”) as tf: tf.write(initial_message) tf.flush() call([EDITOR, tf.name]) # do the parsing with `tf` … Read more

What is the maximum length of a C#/CLI identifier?

In addition to the other answers, the maximum identifier length that is accepted by the Microsoft Visual C# compiler is 511 characters. This can be tested with the following code: class Program { private static void Main(string[] args) { int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 5; } } The length of the variable name there is 511 characters. … Read more