Here I give Linux commands to allow the searching for filenames or strings within files without descending into the <.svn> subdirectories.
Archive for the ‘Shells’ Category
SVN Tip: Find/Grep but excluding .svn (Linux)
Saturday, 5 February 2011SVN: Problems Applying a Patch Cross-platform
Wednesday, 8 December 2010Suppose 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?
Absolute, Relative, and Splitting Paths in Bash
Tuesday, 1 December 2009The 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.
Batch / Bash: Output to STDERR
Friday, 30 October 2009To 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
Batch: Comparing Files
Friday, 30 October 2009( 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.
Batch: Testing for Empty Directories
Thursday, 22 October 2009To 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.
SVNMUCC: Co-tagging and Co-branching
Monday, 19 October 2009In 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.
SVN: Partial Checkouts
Monday, 19 October 2009It 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.
Scripting Links
Monday, 5 October 2009Really good on-line documentation on programming in shell scripting languages seems to be a rarity. On bash, I have found the following invaluable:
- “Advanced Bash-Scripting Guide” in HTML or PDF, hosted by the Linux Documentation Project.
- “An A-Z Index of the Bash command line for Linux“, hosted by ss64.com; see in particular the sections
- Syntax
- Shell Parameters
- Redirection and Process Substitution
- Brackets, including sub-shells and arithmetic
- Conditional Expressions
- Conditional Execution
- Arithmetic Expressions
- Functions
- Syntax
If you really have to do something in MS DOS, then the following is very helpful:
- “An A-Z Index of the Windows XP command line“, again hosted by SS64.com; see in particular the sections
- Syntax
- Parameters
- Redirection
- Conditional Execution
- “Functions“
- SET, including arithmetic
- Syntax