http://docs.python.org/release/2.5.2/ref/pass.html

6.4 The pass statement

pass_stmt ::= "pass"
Download entire grammar as text.
pass is a null operation -- when it is executed, nothing happens. It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed, for example:

def f(arg): pass # a function that does nothing (yet)

class C: pass # a class with no methods (yet)

iPhone 에서 작성된 글입니다.
Posted by code cat

repo sync로 추가된 저장소를 받아와야 한다.(물론 repo안에 manifest에 새로운 git 저장소에 대한 정보를 추가해야 한다.)

그럼 잘 받아오는데, 문제는 받아온 소스를 수정해서 올릴라고 하니까 branch가 없다고 한다.(당연히 없겠지..)

이럴 땐 새로 받아온 git 저장소 내에서 repo start를 실행하여 branch를 넣어주면 된다.

 

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

python, getopt  (0) 2013.04.21
python, pass statement  (0) 2013.04.17
byobu detached 세션 죽이기  (0) 2013.03.13
grep sed 를 이용해 여러 파일에 있는 문자 치환하기  (0) 2013.02.07
gnu make $(eval)  (0) 2012.11.13
Posted by code cat

screen -ls | grep "Detached" | awk '{print $1}' | xargs -i screen -X -S {} quit


Posted by code cat

여러 파일에 있는 특정문자를 다른 바꿀문자로 한번에 바꾸는 방법은 다음과 같다.


grep -rl "특정문자" * | xargs sed -i 's/특정문자/바꿀문자/g'


아 편하다...

Posted by code cat

Using GNU Make's 'define' and '$(eval)' to automate rule creation

About once a week I get an email from someone random asking a question about GNU Make. I do my best to answer and figured it might be helpful for others if I shared these questions and my answers. So, here goes. This one starts with a Princess Leia style appeal:
I stumbled across your name when googling for help on a GNUmake related problem, hope you have the time to look at it as you are my last hope. I have the following problem in my Makefile:
$(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
$(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
$(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
  
$(LIBDIR)/%.a: 
        ar -r $@ $^ 
        ranlib $@
so far, so good - it works as expected. The only problem is, that in the real world it's not just foo, bar and baz for me and I hate having to maintain the list manually. What I would like to do is something like this:
$(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
        ar -r $@ $^ 
        ranlib $@
but now the pattern for filter has two percentage-characters and this seem to confuse GNUmake. I tried to escape it, use $(call …), etc. but nothing really works. Do you have any trick/hint/idea how to solve this??

Thanks for your time, Best Regards,
And my reply:
Thanks for your mail. I can see what you are trying to do. I think the easiest way out of your predicament is as follows:
# Example of manually maintained list 
# 
# $(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
# $(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
# $(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
# 
# $(LIBDIR)/%.a: 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# What you'd like to be able to do 
# 
# $(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# The following will work 
# 
# Suppose, for example: 
 
LIBDIR  := lib 
OBJDIR  := obj 
OBJECTS := $(OBJDIR)/foo/hello.o $(OBJDIR)/foo/bar.o $(OBJDIR)/bar/hello.o \ 
$(OBJDIR)/baz/bar.o 
 
# Extract the names of the first level directories underneath 
# $(OBJDIR) and make a unique list (sort removes duplicates) and store 
# that in LIBNAMES.  This assumes that there are no spaces in any of 
# the filenames in $(OBJECTS) and that each element of $(OBJECTS) 
# starts with $(OBJDIR) 
 
LIBNAMES := $(sort $(foreach a,$(patsubst $(OBJDIR)/%,%,$(OBJECTS)),\ 
$(firstword $(subst /, ,$a)))) 
 
# The following function finds all the objects in $(OBJECTS) in a 
# particular directory whose name can be found in LIBNAMES.  So, in 
# the example here doing $(call find-objects,foo) would return 
# obj/foo/hello.o obj/foo/bar.o 
 
find-objects = $(filter $(OBJDIR)/$1/%,$(OBJECTS)) 
 
# Now need to define the rule that handles each of the libraries 
# mentioned in $(LIBNAMES).  This function can be used with $(eval) to 
# define the rule for a single directory 
 
define make-library  
$(LIBDIR)/lib$1.a: $(call find-objects,$1) 
        ar -r $$@ $$^ 
        ranlib $$@ 
endef 
 
# Now define the rules for all the directories found in $(LIBNAMES) 
 
$(foreach d,$(LIBNAMES),$(eval $(call make-library,$d)))
You will need a version of GNU Make that supports $(eval).

 

Posted by code cat

만일 빼고 싶은 패스가 /home/user/bin이라면, 다음과 같이 하면 된다.

PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')
Posted by code cat

출처: AOSP

소문자 a랑 대문자 B를 text파일(대소문자구별)에 넣고, 소문자로만 된 text파일을 다시 읽어서 무슨 글자가 있나 확인하는 로직이다.  간단하면서 잘 동작한다.

Posted by code cat

Makefile에서 가끔 파일의 존재 여부를 보고 선행 작업을 해줘야 할 때가 있다. 그럴 때는 다음의 간단한 예제를 보고 응용하자.

  (예제를 위한 거니 밑에처럼 하지는 말자...)


Posted by code cat

리눅스에 tar를 이용해서 분할 압축을 할려면,


tar cfz - 압축디렉터리 | split -b 1000m - 압축파일이름.tar.gz_


이렇게 하면 압축파일이름.tar.gz_aa, 압축파일이름.tar.gz_ab, 압축파일이름.tar.gz_ac, ... 

이렇게 분할되어 나온다.


풀 때는,


cat 압축파일이름.tar.gz_* | tar xfz -


로 풀면 된다.

Posted by code cat

git status 했을 때,

# On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
nothing to commit (working directory clean)



이라고 나오면, remote master로 push를 해야 한다.

git remote show origin
을 실행해서 origin/master가 어디인지(git이보기에) 확인하고,

git diff origin/master
를 실행해서 차이점이 있는지 본다.

마지막으로
git push origin

을 실행하면 된다.


'리눅스 > 스크립트/유틸' 카테고리의 다른 글

[Makefile] if 문 사용하여 파일 존재 여부 확인  (0) 2012.10.19
tar 분할 압축하기  (0) 2012.10.17
byobu 로그인 시 자동 실행  (0) 2012.09.27
svn -> git merge 하는 법  (0) 2012.09.19
svn tree conflicts 1  (2) 2012.09.18
Posted by code cat