[mythtv] Ticket #7010: ./cpsvndir causes errors with checkinstall for themes

Michael T. Dean mtdean at thirdcontact.com
Tue Sep 8 16:44:31 UTC 2009


On 09/08/2009 01:07 AM, David Engel wrote:
> On Mon, Sep 07, 2009 at 09:24:52PM -0400, Michael T. Dean wrote:
>   
>> On 09/07/2009 08:43 PM, MythTV wrote:
>>     
>>> What /bin/sh are you using?
>>>       
>> David, this is just a guess (as I don't use *buntu nor dash), but
>> I'm pretty certain Ubuntu is using dash as its default shell.
>>
>> I'm also pretty certain that the problem is all the bashisms in the
>> current script.
>>
>> the
>>
>> IFS=$'\012'
>>
>> is a bashism, that should be
>>
>> IFS='
>> '
>>
>> (where you put a single newline between the ticks) as long as we
>> have #!/bin/sh at the top of the file.
>>     
> It looks like dash, at least the Debian/sid version I have accepts
> either format.
>   

The most-current sh.vim syntax file ( 
http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax ) 
says it only works in bash:

if exists("b:is_bash")
 syn region  shExSingleQuote>---matchgroup=shOperator start=+\$'+ 
skip=+\\\\\|\\.+ end=+'+>-----contains=shStringSpecial,shSpecial
else
 syn region  shExSingleQuote>---matchGroup=Error start=+\$'+ 
skip=+\\\\\|\\.+ end=+'+>----------contains=shStringSpecial
endif

and there are many threads on it not working in dash on the 'net, so I'm 
guessing it's a relatively recent addition to dash.

https://bugs.launchpad.net/ubuntu/+source/dash/+bug/285651
http://www.mail-archive.com/dash@vger.kernel.org/msg00099.html

>> Also, $(<command>) is a bashism that should be, i.e.:
>>
>> for directory in `find "$1" -path '*/.svn' -prune -or -type d -print`; do
>>
>> (though I think that one works on dash).
>>     
> I know $(command) is definitely standard POSIX.  Furthermore, dash
> accepts it so this isn't it.
>   

Yeah, it turns out that's marked because--though it's supported by most 
modern shells--it doesn't work on Solaris/IRIX /bin/sh.

I probably should have said, "non-portable," rather than, "bashism."

 From the comments of the syntax file:

" $() and $(()): {{{1
" $(..) is not supported by sh (Bourne shell).  However, apparently
" some systems (HP?) have as their /bin/sh a (link to) Korn shell
" (ie. Posix compliant shell).  /bin/ksh should work for those
" systems too, however, so the following syntax will flag $(..) as
" an Error under /bin/sh.  By consensus of vimdev'ers!

>> Unfortunately, I don't know how to do the bash regexp-type stuff:
>>
>> ${1##*/}
>>
>> without bash.  I think these are causing some problems on dash.
>>     
> That's standard POSIX, too.  dash also accepts it.
>   

That and all of the parameter expansion with # in them are marked in the 
syntax file to work only for bash or korn shell:

"    ksh bash : ${parameter#pattern}  remove small left  pattern
"    ksh bash : ${parameter##pattern} remove large left  pattern
"    ksh bash : ${parameter%pattern}  remove small right pattern
"    ksh bash : ${parameter%%pattern} remove large right pattern

>> If you open up the file in a vim with a sh syntax file and
>> highlighting enabled, you'll see all the bashism's (or, at least,
>> non-standard sh syntax) marked in "error" color (red on mine).
>>     
> The culprit is the ${var/#Pattern/Replacement} replacement.

And that is marked bash only:

 " bash : ${parameter//pattern/string}
 " bash : ${parameter//pattern}

>   Unless
> someone comes up with a better way, I'm inclined to implement the
> nuclear option.  That is to do a simple "cp -r" followed by a find to
> delete any and all .svn directories under the destination.
>
> Actually, I think I might have a better way, but I'm not going to work
> on it anymore until tomorrow.

Thanks for taking the time to work through it all.  It's probably not a 
big deal to "fix" all of the places I mentioned since some of the 
portability issues will affect only a very small number of shells in use 
today.  As long as the script works on the shells (and versions of the 
shells) used by the users who run make install, it's good enough.

Thanks,
Mike


More information about the mythtv-dev mailing list