P/Invoke Tutorial: Pinning (Part 4)

Sometimes a C/C++ function needs to store data you pass to it for later reference. If such data is a managed object (like a string or class) you need to make sure that the garbage collector doesn’t delete it while it’s still used/stored in the native code.

That’s what pinning is for. It prevents the garbage collector from deleting and moving the object.

Read more →

Bash variable inheritances cheat sheet

Just a quick cheat sheet about how variables in Bash get inherited.

Result

Here’s the result of a call to outer.sh (see below):

Call
-------
From Outer (export):    yes
From Outer (no export):
From Inner (export):
From Inner (no export):

Source
-------
From Outer (export):    yes
From Outer (no export): yes
From Inner (export):    yes
From Inner (no export): yes

Test

The test consists of two files: outer.sh and inner.sh.

outer.sh is called by the user and internally calls inner.sh – once directly and once with source.

Contents of outer.sh:

#!/bin/bash

export FROM_OUTER_EXPORT="yes"
FROM_OUTER_NO_EXPORT="yes"

echo "Call"
echo "-------"
./inner.sh
echo "From Inner (export):    $FROM_INNER_EXPORT"
echo "From Inner (no export): $FROM_INNER_NO_EXPORT"

echo 
echo "Source"
echo "-------"
source ./inner.sh
echo "From Inner (export):    $FROM_INNER_EXPORT"
echo "From Inner (no export): $FROM_INNER_NO_EXPORT"

Contents of inner.sh:

#!/bin/bash

echo "From Outer (export):    $FROM_OUTER_EXPORT"
echo "From Outer (no export): $FROM_OUTER_NO_EXPORT"

export FROM_INNER_EXPORT="yes"
FROM_INNER_NO_EXPORT="yes"

Skipping Unreadable Pattern File Error in Mercurial

I had it happened a couple of times now that Mercurial on Windows would give me this error:

skipping unreadable pattern file ‘D:\Documents\Programming\YourProject\’: No such file or directory

This message is strange because the path actually exits.

After some searching I found the solution in the Mercurial bug tracker:

Bug 5325 – “skipping unreadable pattern file” by empty ui.ignore

The title already suggests the solution. There’s an empty ignore= entry in the global mercurial.ini file.

mercurial-ini.png

Removing this entry solves the problem.

The file is located here:

C:\Users\<YourUserName>\mercurial.ini

Note: It seems this “problem” is caused by SourceTree.

Quick Tip: Start Docker Toolbox Shell via Batch

Are you still stuck with Windows 8.1 or earlier? Then, if you want to use Docker, you have to use the Docker Toolbox.

Docker Toolbox comes with its own “shell” called Docker Quickstart Terminal. It uses Windows’ own command window – which is pretty limited.

docker-shell.png

As I explored in Command Line Replacement For Windows, there are alternatives.

To be able to interact with Docker Toolbox in these alternative command line tools, you can create a simple batch file that drops you into the same Docker shell as the “Docker Quickstart Terminal”:

@echo off
setlocal
cd /D %DOCKER_TOOLBOX_INSTALL_PATH%
"%GIT_INSTALL_ROOT%\bin\bash.exe" --login -i "%DOCKER_TOOLBOX_INSTALL_PATH%\start.sh"

Command Line Replacement For Windows

Even though Windows has a command line, this command line is very limited when compared to the ones available on Mac or Linux.

Fortunately, there are (free) alternatives out there. In this article we’ll be looking at three of them: ConsoleZ, ConEmu, and Cmder

At the end of the day, we’re looking for the best tool. So I’ve assembled a comparison chart for these three tools to find out which one is the best for me and you.

Read more →