SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Bash script which adds a line before every curly brackets

    Hello,
    I need to create a bash script that adds a row before every curly bracket for functions, classes (classes and methods) and try/catch blocks in PHP code.

    I think using the program in conjunction with sed
    E.G. : find . -type f \( -name "*.php \) -exec sed .......

    For example:

    PHP Code:
    <?php
    function my_function() {

    }
    Becomes:

    PHP Code:
    <?php
    function my_function() 
    {

    }
    Can you help me so that I can achieve this, please?

    Thank you!

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,313
    Mentioned
    178 Post(s)
    Tagged
    9 Thread(s)
    Hi,
    Not much good at Bash, but this would be quite simple in Ruby.
    Do you have access to Ruby?

  3. #3
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,514
    Mentioned
    37 Post(s)
    Tagged
    1 Thread(s)
    Might be worth looking at this http://phptidy.berlios.de/
    or php beautifier

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    There's several IDEs out there that have code formatting scripts. I believe Eclipse is one of them, though I'm not sure if you can customize it to what you want.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •