Archive for the ‘Shells’ Category

SVN Tip: Find/Grep but excluding .svn (Linux)

Saturday, 5 February 2011

Here I give Linux commands to allow the searching for filenames or strings within files without descending into the <.svn> subdirectories.

(more…)

Advertisements

SVN: Problems Applying a Patch Cross-platform

Wednesday, 8 December 2010

Suppose you have a set of changes on a Windows machine ready for commit. However, before committing, you’d like to check compilation on your Linux box. So, you create a patch file with a command such as

C:\my-dir> svn diff > patch.diff

Having copied the patch to your Linux box, you try the command

/home/me/my-dir$ patch -p0 < patch.diff

Unfortunately, you see many problems of the form

Hunk #1 FAILED at 234.

What is wrong?

(more…)

Absolute, Relative, and Splitting Paths in Bash

Tuesday, 1 December 2009

The main stumbling block with splitting paths in Bash is converting a relative path into an absolute one.

Searching the Internet I found many partial solutions, but none was entirely satisfactory. There may be a better solution out there, but I didn’t find it.

(more…)

Batch / Bash: Output to STDERR

Friday, 30 October 2009

To output a message to the error stream in a batch file, simply do this:

echo your message text 1>&2

Similar syntax may be used in Bash shell scripts:

echo "your message text" 1>&2

(more…)

Batch: Comparing Files

Friday, 30 October 2009
The trick to testing file contents is to do something like this:

( fc /B "%file1%" "%file2%" | find "FC: no differences encountered" ) > nul && (
  echo "%file1%" and "%file2%" are the same
) || (
  echo "%file1%" and "%file2%" are different
)

using conditional execution.

(more…)

Batch: Testing for Empty Directories

Thursday, 22 October 2009

To test whether a directory (or “folder”) is empty, the code

if exist "%dir%\*.*" (
  echo %dir% is non-empty
) else (
  echo %dir% is empty
)

does not work; it always reports “non-empty”.

The trick

( dir /b /a "%dir%" | findstr . ) > nul && (
  echo %dir% non-empty
) || (
  echo %dir% empty
)

using conditional execution, however, does work.

(more…)

SVNMUCC: Co-tagging and Co-branching

Monday, 19 October 2009

In a previous post, I mentioned co-tagging.

Here are a couple of scripts, one Bash shell script, and the equivalent DOS Batch file, to assist with co-tagging and similarly with co-branching.

(more…)

SVN: Partial Checkouts

Monday, 19 October 2009

It is often useful to be able to partially checkout a project or a subset of related projects from a repository. Having such a partial working copy may be helpful to allow the joint commit of related changes to more than one project. Thus helps to “tie” the changes in the projects’ histories.

Here are a couple of scripts to assist that process: one Bash shell script, and the equivalent DOS Batch file.

(more…)

Scripting Links

Monday, 5 October 2009

Really good on-line documentation on programming in shell scripting languages seems to be a rarity. On bash, I have found the following invaluable:

If you really have to do something in MS DOS, then the following is very helpful:

MS-DOS Batch Tip: Function Calls, Parameters and Filenames

Wednesday, 17 June 2009

Here’s something I discovered by accident whilst using features I learned from the excellent site SS64.com site whilst struggling with the limitations of Batch.

(more…)