OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [utils/] [contributions/] [setup/] [beautify.sh] - Blame information for rev 42

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 41 rfajardo
#!/bin/bash
2
# Xanthopoulos Constantinos
3
# Some useful function for my scripts
4
 
5
function cecho
6
{
7
         echo -e "\033[1m\033[33m$1\033[0m"
8
}
9
 
10
function errormsg
11
{
12
        echo -e "\033[1m\033[31mError: $1\033[0m\n";
13
        exit 1;
14
}
15
 
16
function readpass
17
{
18
        stty_orig=`stty -g`
19
        stty -echo
20
        read `echo $1`
21
        stty $stty_orig
22
}
23
 
24
function execcmd
25
{
26
        # Print Message
27
        echo -e "\033[35m$1\033[0m"
28
        # Execute command
29
        echo $2
30
        if [ $DEBUG -ne 1 ];
31
        then
32
                eval $2;
33
        fi;
34
        # Check Execution
35
        if [ $? -eq 0 ]
36
        then
37
                echo -e "\033[32mSuccessfully \"$1\"\033[0m\n";
38
        else
39
                errormsg "$1";
40
                exit 1;
41
 
42
        fi
43
}
44
 
45
function changelinefile
46
{
47
        a=0;
48
        b=0;
49
        sed -e "s/$1/$2/" $3 > /tmp/changedfile;
50
        if [ $? -eq 0 ]
51
        then
52
                a=1;
53
        fi
54
        mv /tmp/changedfile $3;
55
        if [ $? -eq 0 ]
56
        then
57
                b=1;
58
        fi
59
        execcmd "Change file $3" "test $a -eq 1 -a $b -eq 1"
60
}
61
 
62
if [ $DEBUG -eq 1 ]
63
then
64
        cecho "Debug mode on! Nothing will actually run";
65
fi

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.