Archive for October, 2009

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…)

Advertisements

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…)

JSP & JSTL: Setting a Variable to the Content of an XPath

Wednesday, 21 October 2009

I had a problem in JSP and JSTL where I could not get a core variable to contain the content of an XML XPath expression.

Following a combination of reading a book, searching the Internet and speaking to a colleague, I found two solutions to my problem, but unfortunately not an answer to the question of why my original code does not 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…)

SVN and T-SVN: Key Notes on Merging Branches

Monday, 19 October 2009

In trying to provide a colleague with some help on merging with SVN, especially with the new “mergeinfo” functionality, I discovered a number of things that anyone doing branching and merging with SVN (Subversion) or T-SVN (TortoiseSVN) should know.

(more…)

T-SVN Tip: Browse Repository Short-cuts

Saturday, 17 October 2009

You might find it useful to have a short-cut to a repository on your Windoze Desktop.

Suppose the URL of the area of interest is

http://server/repos/project/trunk

If you have a repository that is served locally, rather than via Apache HTTP, the URL will be more like

file://localhost/C:/dir/repos/project/trunk

Simply create a new shortcut with the target

"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"
    /command:repobrowser
    /path:"http://server/repos/project/trunk"

Similarly, the repository browser could be launched from within a batch file in a similar way:

@echo off
start "Project Trunk" "C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"
        /command:repobrowser /path:"http://server/repos/project/trunk"

[This information may be found in the TortoiseSVN documentation.]

Python Source Code Encodings

Saturday, 17 October 2009

If when you try to run a fragment of python like this:

#!/usr/bin/python

### comment with a £pound sign
if __name__ == '__main__':
  pass

you get an error such as

SyntaxError: Non-ASCII character '\xa3' in file main.py on line 3,
  but no encoding declared ...

then what you need is an encoding declaration on the first or second line of the file.

(more…)

Boost DateTime, Locales and Facets

Saturday, 17 October 2009

Boost DateTime extends the standard library facets for formatting dates and times according to locale.

I have had some trouble with these libraries. It seems that there is something of a flaw in the design of the standard library locales. Following are some functions that look like they work but don’t, and one that work, but looks like it shouldn’t.

(more…)