Using Special Characters

Special shell characters and the p4 command

Info & Tags

Article #:
41
Created:
04/25/07
Modified:
05/26/08

Task

How to you work around special characters on the p4 command line?

Solution

Perforce uses the characters * and # in file specifications. These characters also have special meaning in many command shells, which may require you to use quotes in your p4 commands. (On Unix, use single quotes; in the Windows MS-DOS shell,
use double quotes.)

Example using # symbol

	p4 sync #none

should remove all depot files from your workspace. If you find that what happens instead is that it syncs your entire workspace to head revisions, it's because your command shell interprets # as a comment character. If this happens, try:

	p4 sync '#none'

Example using asterisk

Or, for instance, if a command like

	p4 files stuff/*

complains "no files found," it may be because your command shell is trying to expand the * wildcard before Perforce even sees it. There are a number of ways you can use quotes. For example:

MS-DOS p4 files "stuff/*"
p4 files stuff/"*"

Unix p4 files 'stuff/*'
p4 files stuff/'*'
p4 files stuff/*

Also, you can use the Perforce wildcard %1, which means the same as * but isn't special to most shells:

	p4 files stuff/%1

(Note that this wouldn't work in MS-DOS batch scripts, where %1 is special.)

Notes about the double forward slash

Perforce also makes frequent use of the double forward slash character combination "//" when referencing file paths. The // character combination may be interpreted by your shell as referencing a Universal Name Convention (UNC) path instead of a Perforce depot or client workspace path. If you experience abnormally long delays in getting results from Perforce commands using the //depot or //clientname syntax, try quoting the entire path string. In general, only Unix shells on Windows are susceptible to this particular problem. For delays related to other network issues, see Isolating Network Problems