Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 867053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:54:42+00:00 2026-05-15T09:54:42+00:00

Using Perforce, I’d like to be able to reject submits which contain files with

  • 0

Using Perforce, I’d like to be able to reject submits which contain files with Windows line endings (\r\n IIRC, maybe just \r anywhere as really we only want files with Unix line endings).

Rather than dos2unix incoming files or similar, to help track down instances where users attempt to submit files with Windows line endings, I’d like to add a trigger to reject text submissions which contain files with non-Unix line endings.

Could someone demonstrate how the trigger itself could be written, perhaps with bash or python?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:54:43+00:00Added an answer on May 15, 2026 at 9:54 am

    Here’s the minimal edit I can thing of for the bash example found in the p4 docs:

    #!/bin/sh
    # Set target string, files to search, location of p4 executable...
    TARGET='\r\n'
    DEPOT_PATH="//depot/src/..."
    CHANGE=$1
    P4CMD="/usr/local/bin/p4 -p 1666 -c copychecker"
    XIT=0
    echo ""
    # For each file, strip off #version and other non-filename info
    # Use sed to swap spaces w/"%" to obtain single arguments for "for"
    for FILE in `$P4CMD files $DEPOT_PATH@=$CHANGE | \
      sed -e 's/\(.*\)\#[0-9]* - .*$/\1/' -e 's/ /%/g'`
    do
      # Undo the replacement to obtain filename...
      FILE="`echo $FILE | sed -e 's/%/ /g'`"
    # ...and use @= specifier to access file contents:
      # p4 print -q //depot/src/file.c@=12345
      if $P4CMD print -q "$FILE@=$CHANGE" | fgrep "$TARGET" > /dev/null
      then 
          echo "Submit fails: '$TARGET' not found in $FILE"
          XIT=1
      else
          echo ""
    
      fi
    done
    exit $XIT
    

    The original example fails if the target is missing, this one fails if it’s present — just switching the then and else branches of the if. You could edit it further of course (e.g. giving grep, or fgrep, the -q flag to suppress output, if your grep supports it as e.g. GNU’s does).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Perforce with Vim on Windows. I currently have an auto command set
We're using Perforce and Visual Studio. Whenever we create a branch, some projects will
Right now, we are using Perforce for version control. It has the handy feature
I'm using P4COM to communicate with our perforce server. I have written an little
I'm using Perforce, if that changes the tune of the answers at all. I'd
Note: Currently using Perforce as a CM tool. I currently do several debug releases
we are using Perforce for source configuration management and I have just started to
I'm using perforce for versioning control. Let's say I am working on a file
Is it possible to mount a local directory into another one? Using Perforce, I
In Perforce P4V, I'd like to do a search for all changelists that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.