List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH v2 1/1] syntax-highlight: when the file has no extension, assume text
@ 2012-04-04 16:15 mailings
  2012-04-04 16:58 ` cgit
  0 siblings, 1 reply; 5+ messages in thread
From: mailings @ 2012-04-04 16:15 UTC (permalink / raw)


From: Ferry Huberts <ferry.huberts at pelagic.nl>

There are 2 situations:
1- empty extension: assuming text is better than highlight
   producing no output because of a missing argument.
2- no extension at all: assuming text is better than setting
   the extension to the filename, which is what now happens.

Signed-off-by: Ferry Huberts <ferry.huberts at pelagic.nl>
---
 filters/syntax-highlighting.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 5fcc9c9..8b09180 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -39,6 +39,9 @@
 BASENAME="$1"
 EXTENSION="${BASENAME##*.}"
 
+[ "${BASENAME}" == "${EXTENSION}" ] && EXTENSION=txt
+[ -z "${EXTENSION}" ] && EXTENSION=txt
+
 # map Makefile and Makefile.* to .mk
 [ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
 
-- 
1.7.7.6





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] syntax-highlight: when the file has no extension,  assume text
  2012-04-04 16:15 [PATCH v2 1/1] syntax-highlight: when the file has no extension, assume text mailings
@ 2012-04-04 16:58 ` cgit
  2012-04-04 17:07   ` mailings
  0 siblings, 1 reply; 5+ messages in thread
From: cgit @ 2012-04-04 16:58 UTC (permalink / raw)


On Wed, Apr 04, 2012 at 06:15:02PM +0200, Ferry Huberts wrote:
> From: Ferry Huberts <ferry.huberts at pelagic.nl>
> 
> There are 2 situations:
> 1- empty extension: assuming text is better than highlight
>    producing no output because of a missing argument.
> 2- no extension at all: assuming text is better than setting
>    the extension to the filename, which is what now happens.
> 
> Signed-off-by: Ferry Huberts <ferry.huberts at pelagic.nl>
> ---
>  filters/syntax-highlighting.sh |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
> index 5fcc9c9..8b09180 100755
> --- a/filters/syntax-highlighting.sh
> +++ b/filters/syntax-highlighting.sh
> @@ -39,6 +39,9 @@
>  BASENAME="$1"
>  EXTENSION="${BASENAME##*.}"
>  
> +[ "${BASENAME}" == "${EXTENSION}" ] && EXTENSION=txt

There is no "==" in POSIX shell/test(1). This should probably be a
single equal sign ("=").

> +[ -z "${EXTENSION}" ] && EXTENSION=txt
> +
>  # map Makefile and Makefile.* to .mk
>  [ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
>  
> -- 
> 1.7.7.6
> 
> 
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] syntax-highlight: when the file has no extension,  assume text
  2012-04-04 16:58 ` cgit
@ 2012-04-04 17:07   ` mailings
  2012-04-05  9:38     ` nobody
  0 siblings, 1 reply; 5+ messages in thread
From: mailings @ 2012-04-04 17:07 UTC (permalink / raw)




On 04-04-12 18:58, Lukas Fleischer wrote:
> On Wed, Apr 04, 2012 at 06:15:02PM +0200, Ferry Huberts wrote:
>> From: Ferry Huberts<ferry.huberts at pelagic.nl>
>>
>> There are 2 situations:
>> 1- empty extension: assuming text is better than highlight
>>     producing no output because of a missing argument.
>> 2- no extension at all: assuming text is better than setting
>>     the extension to the filename, which is what now happens.
>>
>> Signed-off-by: Ferry Huberts<ferry.huberts at pelagic.nl>
>> ---
>>   filters/syntax-highlighting.sh |    3 +++
>>   1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
>> index 5fcc9c9..8b09180 100755
>> --- a/filters/syntax-highlighting.sh
>> +++ b/filters/syntax-highlighting.sh
>> @@ -39,6 +39,9 @@
>>   BASENAME="$1"
>>   EXTENSION="${BASENAME##*.}"
>>
>> +[ "${BASENAME}" == "${EXTENSION}" ]&&  EXTENSION=txt
>
> There is no "==" in POSIX shell/test(1). This should probably be a
> single equal sign ("=").
>
>> +[ -z "${EXTENSION}" ]&&  EXTENSION=txt
>> +
>>   # map Makefile and Makefile.* to .mk
>>   [ "${BASENAME%%.*}" == "Makefile" ]&&  EXTENSION=mk
>>

it appears there is, or (if there is not) the line above also doesn't 
work (that line has been in since 56522eb, 19-11-2009)



-- 
Ferry Huberts




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] syntax-highlight: when the file has no extension,  assume text
  2012-04-04 17:07   ` mailings
@ 2012-04-05  9:38     ` nobody
  2012-04-05 10:04       ` mailings
  0 siblings, 1 reply; 5+ messages in thread
From: nobody @ 2012-04-05  9:38 UTC (permalink / raw)


On 04/04/2012 07:07 PM, Ferry Huberts wrote:
> On 04-04-12 18:58, Lukas Fleischer wrote:
>> There is no "==" in POSIX shell/test(1). This should probably be a
>> single equal sign ("=").

> it appears there is, or (if there is not) the line above also doesn't
> work (that line has been in since 56522eb, 19-11-2009)

$ cat << EOF > test.sh
if [ "magic" == "\$1" ]; then
    echo "Argument is magic."
fi
EOF
$ /bin/dash test.sh
[: 3: magic: unexpected operator
$ /bin/dash test.sh magic
[: 3: magic: unexpected operator
$ sed -e 's/==/=/' -i test.sh
$ /bin/dash test.sh
$ /bin/dash test.sh magic
Argument is magic.
$ /bin/bash test.sh
$ /bin/bash test.sh magic
Argument is magic.

dash is a posix compatible shell. As most people use bash as their
shell, incompatibilies with posix shell often go unnoticed for a long
time. A script should however either specify /bin/bash as interpreter
or adhere to the shell language given in POSIX.

Best Regards,
Christian




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] syntax-highlight: when the file has no extension,  assume text
  2012-04-05  9:38     ` nobody
@ 2012-04-05 10:04       ` mailings
  0 siblings, 0 replies; 5+ messages in thread
From: mailings @ 2012-04-05 10:04 UTC (permalink / raw)




On 05-04-12 11:38, Christian Franke wrote:
> On 04/04/2012 07:07 PM, Ferry Huberts wrote:
>> On 04-04-12 18:58, Lukas Fleischer wrote:
>>> There is no "==" in POSIX shell/test(1). This should probably be a
>>> single equal sign ("=").
>
>> it appears there is, or (if there is not) the line above also doesn't
>> work (that line has been in since 56522eb, 19-11-2009)
>
> $ cat<<  EOF>  test.sh
> if [ "magic" == "\$1" ]; then
>      echo "Argument is magic."
> fi
> EOF
> $ /bin/dash test.sh
> [: 3: magic: unexpected operator
> $ /bin/dash test.sh magic
> [: 3: magic: unexpected operator
> $ sed -e 's/==/=/' -i test.sh
> $ /bin/dash test.sh
> $ /bin/dash test.sh magic
> Argument is magic.
> $ /bin/bash test.sh
> $ /bin/bash test.sh magic
> Argument is magic.
>
> dash is a posix compatible shell. As most people use bash as their
> shell, incompatibilies with posix shell often go unnoticed for a long
> time. A script should however either specify /bin/bash as interpreter
> or adhere to the shell language given in POSIX.
>
> Best Regards,
> Christian

ok, thanks for the demo

I'll post a follow-up patch that fixes the POSIX issues

-- 
Ferry Huberts




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-05 10:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04 16:15 [PATCH v2 1/1] syntax-highlight: when the file has no extension, assume text mailings
2012-04-04 16:58 ` cgit
2012-04-04 17:07   ` mailings
2012-04-05  9:38     ` nobody
2012-04-05 10:04       ` mailings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).