Patchwork [7,of,7,v2] tests: add test-check-execute.t

login
register
mail settings
Submitter timeless
Date Dec. 30, 2015, 4:43 a.m.
Message ID <CAAKMeYj+_T6Bmy==Gk3t=_RKgFw48ammHugHsjqOZkNg67bn6g@mail.gmail.com>
Download mbox | patch
Permalink /patch/12413/
State Superseded
Commit b3eba79b7e0414861cac8e427606e0784ace459b
Headers show

Comments

timeless - Dec. 30, 2015, 4:43 a.m.
Ok, i've played around with hg grep. It's unusable.

* a file that *used* to match something would be reported (e.py)
* restricting revisions to the current one (-r .) means we wouldn't
catch files added by FAT users

$ hg files 'set:(**.py) and not exec()'|xargs hg grep -l -r .
"^[^\n]*(env |/)python"
$ hg files 'set:(**.py) and not exec()'|xargs hg grep -l "^[^\n]*(env |/)python"
e.py:6
d.py:3
c.py:2
$ cat e.py
$
$ hg log -pv|cat
changeset:   7:5fc909ffd6a7
tag:         tip
user:        timeless@gmail.com
date:        Wed Dec 30 04:40:00 2015 +0000
files:       e.py
description:
removing shbang from e



changeset:   1:9ec3f6bd61b8
user:        timeless@gmail.com
date:        Wed Dec 30 04:35:16 2015 +0000
files:       b.py
description:
b exec without shbang



changeset:   0:877a6c673c14
user:        timeless@gmail.com
date:        Wed Dec 30 04:34:51 2015 +0000
files:       a.sh
description:
a exec without shbang

On Tue, Dec 29, 2015 at 10:50 PM, timeless <timeless@gmail.com> wrote:
> On Tue, Dec 29, 2015 at 9:31 PM, Yuya Nishihara <yuya@tcha.org> wrote:
>>> I tested w/ a FAT filesystem on OS X, and the set:exec() fileset
>>> properly returned only files w/ +x from the repo, even though they all
>>> appear to have +x according to ls.
>>
>> That only applies to committed files. If you add a new file on FAT, it can't
>> be marked as an executable.
>
>> That said, do you think Windows people should be blamed if they add an
>> executable with no executable bit? If so, no "#require execbit" would make
>> sense.
>
> To be honest, I consider this a bug in hg. I should be able to set the
> execute information while using a fat file system. It's just metadata.
> And we can clearly record and report it.
>
> That said, I guess I'm ok w/ doing a require execbit for now...
>
>>> >> +look for python scripts without the execute bit
>>> >> +
>>> >> +  $ hg files 'set:(**.py) and not exec()' 2> /dev/null | \
>>> >> +  > xargs -n1 egrep -n -H '(env |/)python'|grep ':1:' | \
>>> >> +  > cat
>>> >
>>> > You can use grep() fileset.
>>>
>>> I can't. grep() doesn't give me line numbers.
>>> I'm not asking "does this file have `env python`/`python`, I'm asking
>>> "does the first line of this file have that" -- I'm doing that using
>>> `-n` and :1: (the -H is to handle the case where there's only one
>>> file).
>>
>> grep() uses re.search(), in which MULTILINE is off by default. "^" only
>> matches the first line. You can also use "\A".
>>
>> https://docs.python.org/2.7/library/re.html
>>
>> FWIW, '(env |/)python' doesn't work on Windows because of "/".
>
> ok. Unqueue this and I'll revisit it...
Yuya Nishihara - Dec. 30, 2015, 5:05 a.m.
On Tue, 29 Dec 2015 23:43:44 -0500, timeless wrote:
> Ok, i've played around with hg grep. It's unusable.
> 
> * a file that *used* to match something would be reported (e.py)
> * restricting revisions to the current one (-r .) means we wouldn't
> catch files added by FAT users
> 
> $ hg files 'set:(**.py) and not exec()'|xargs hg grep -l -r .
> "^[^\n]*(env |/)python"
> $ hg files 'set:(**.py) and not exec()'|xargs hg grep -l "^[^\n]*(env |/)python"
> e.py:6
> d.py:3
> c.py:2

I meant it could use grep() fileset.

  $ hg files 'set:**.py and not exec() and grep(r"^#!.*?python")'
timeless - Dec. 30, 2015, 5:24 a.m.
Yuya Nishihara wrote:
> I meant it could use grep() fileset.
>
>   $ hg files 'set:**.py and not exec() and grep(r"^#!.*?python")'

doh. Thanks.
i've sent a new resend (when "searching for changes" finishes...)

Patch

diff -r 00ea3cd290e4 -r 5fc909ffd6a7 e.py
--- a/e.py    Wed Dec 30 04:39:45 2015 +0000
+++ b/e.py    Wed Dec 30 04:40:00 2015 +0000
@@ -1,1 +0,0 @@ 
-#!env python

changeset:   6:00ea3cd290e4
user:        timeless@gmail.com
date:        Wed Dec 30 04:39:45 2015 +0000
files:       e.py
description:
copying c as e, to remove shbang


diff -r 67c115063d67 -r 00ea3cd290e4 e.py
--- /dev/null    Thu Jan 01 00:00:00 1970 +0000
+++ b/e.py    Wed Dec 30 04:39:45 2015 +0000
@@ -0,0 +1,1 @@ 
+#!env python

changeset:   5:67c115063d67
user:        timeless@gmail.com
date:        Wed Dec 30 04:38:29 2015 +0000
files:       c-deleted.py d-deleted.py
description:
deleting


diff -r 2fa7accad88b -r 67c115063d67 c-deleted.py
--- a/c-deleted.py    Wed Dec 30 04:38:17 2015 +0000
+++ /dev/null    Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@ 
-#!env python
diff -r 2fa7accad88b -r 67c115063d67 d-deleted.py
--- a/d-deleted.py    Wed Dec 30 04:38:17 2015 +0000
+++ /dev/null    Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@ 
-
-#!env python

changeset:   4:2fa7accad88b
user:        timeless@gmail.com
date:        Wed Dec 30 04:38:17 2015 +0000
files:       c-deleted.py d-deleted.py
description:
copy to delete


diff -r 5aa3086074b7 -r 2fa7accad88b c-deleted.py
--- /dev/null    Thu Jan 01 00:00:00 1970 +0000
+++ b/c-deleted.py    Wed Dec 30 04:38:17 2015 +0000
@@ -0,0 +1,1 @@ 
+#!env python
diff -r 5aa3086074b7 -r 2fa7accad88b d-deleted.py
--- /dev/null    Thu Jan 01 00:00:00 1970 +0000
+++ b/d-deleted.py    Wed Dec 30 04:38:17 2015 +0000
@@ -0,0 +1,2 @@ 
+
+#!env python

changeset:   3:5aa3086074b7
user:        timeless@gmail.com
date:        Wed Dec 30 04:36:58 2015 +0000
files:       d.py
description:
c no-exec with false shbang


diff -r b6b350537b0c -r 5aa3086074b7 d.py
--- /dev/null    Thu Jan 01 00:00:00 1970 +0000
+++ b/d.py    Wed Dec 30 04:36:58 2015 +0000
@@ -0,0 +1,2 @@ 
+
+#!env python

changeset:   2:b6b350537b0c
user:        timeless@gmail.com
date:        Wed Dec 30 04:36:10 2015 +0000
files:       c.py
description:
c no-exec with shbang


diff -r 9ec3f6bd61b8 -r b6b350537b0c c.py
--- /dev/null    Thu Jan 01 00:00:00 1970 +0000
+++ b/c.py    Wed Dec 30 04:36:10 2015 +0000
@@ -0,0 +1,1 @@ 
+#!env python