I want to list the changes to a perforce repo that have occurred after the last integration.  I can use the changelist number of the last integration, with the ‘p4 changes’ command, to get what I want.

]$ p4 changes -l -s submitted //repository/path/to/the/files/…’@>CHANGELIST_NUMBER’

Great!  Now, make it a bash script, so I don’t have type that all out every time… hey! WTF, bash?  You have a problems expanding variables in single quotes, don’t you?  I tried a bunch of different single double escaped tick quote combinations.  I liked:

unexpected EOF while looking for matching `”‘


syntax error: unexpected end of file

… but my favorite was

Invalid changelist/client/label/date ‘@>16436’ ‘. <– not bash adding 2 single quotes here…


Here is what I ended up with (where the $1 is the first param I’m passing to my script)

p4 changes -l -s submitted //xddev/nbc/livestreaming/development/…”‘” “@>$1” “‘” > changes.txt

That is some mad bash double quote single quote action.  It also would not work until I added spaces before and after the middle double quoted bit.

Yeeeeeeeeee-ikes.  Srsly.

Now that I’ve won, I can rest assured that the hour it took to sort that out was worth it.  I only have to use that command 483 times, and I gain back the hour, and start saving time!  Of course, now I want spend that making bombs and mailing them to the people responsible, but that is so last century.  Instead, I’ll have to go Occupy a park near their house, and shout things at them with a bullhorn.





Comments are closed.