Tiny Core Linux

Off-Topic => Archive / Obsolete => SCM EXtensions => Topic started by: uggla on April 27, 2012, 07:06:06 AM

Title: Abiword.scm command line bug
Post by: uggla on April 27, 2012, 07:06:06 AM
With the current /apps/abiword/bin/abiword the following command doesn't work:
abiword mydoc.abw

Title: Re: Abiword.scm command line bug
Post by: Jason W on April 27, 2012, 07:17:45 AM
Likely I forgot to use this command in the wrapper:

..../abiword "$@"

That last part is what passes arguments to the app being launched.  I will look into it tonight.
Title: Re: Abiword.scm command line bug
Post by: uggla on April 27, 2012, 07:36:18 AM
No I think its cd /apps/abiword

Code: [Select]
#!/bin/sh

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

/apps/abiword/abiword "$@"
Title: Re: Abiword.scm command line bug
Post by: Jason W on April 27, 2012, 08:40:11 AM
Ok, abiword has to be called from it's existing location to work, but I will see what I can do.
Title: Re: Abiword.scm command line bug
Post by: Rich on April 27, 2012, 08:57:49 AM
Hi Jason W
Would a full path instead of a relative one in the export commands help, or would that cause problems
with other extensions?
Title: Re: Abiword.scm command line bug
Post by: uggla on April 27, 2012, 10:10:42 AM
vlc.scm has the same bug.
Title: Re: Abiword.scm command line bug
Post by: Jason W on April 27, 2012, 10:32:11 AM
Those apps that were converted from tcz's have to be run from the directory above the local/ one in the extension.  That is the reason for the cd command used.

It is kind of a hack to allow converted extensions to work, though it does interfere with command line use.   The relative path used in exporting is due to already being in the right directory, and using an absolute path won't let us run the app from just any dir.

I will look into perhaps another way of making the app work while also being able to be used properly from the command line.   But I am basically done with converting existing tcz's, so eventually I or someone will build or rebuild the apps outright from source.   Converting did help with providing an initial repo, but there are many potential pitfalls with it.
Title: Re: Abiword.scm command line bug
Post by: Rich on April 27, 2012, 10:45:52 AM
Hi Jason W
May something like this would work:?
Code: [Select]
#!/bin/sh

pwd=`echo $PWD`

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

/apps/abiword/abiword "$pwd/$@"
Title: Re: Abiword.scm command line bug
Post by: Jason W on April 27, 2012, 11:30:38 AM
I will certainly try it, although with command line switches it may interfere, but we will see.
Title: Re: Abiword.scm command line bug
Post by: Rich on April 27, 2012, 11:55:22 AM
Hi Jason W
Quote
with command line switches it may interfere
That had not occurred to me. It will also fail if someone gives an absolute path for a file, so this may be better:
Code: [Select]
#!/bin/sh

pwd=`echo $PWD`/   # Added slash here

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

[[ ${@:0:1} == "/" ]] && pwd="" # Don't insert path if there's a leading slash

/apps/abiword/abiword "$pwd$@"   # Removed slash from here
Title: Re: Abiword.scm command line bug
Post by: Jason W on April 28, 2012, 11:38:12 AM
Thanks Rich, I will check those out.
Title: Re: Abiword.scm command line bug
Post by: curaga on April 28, 2012, 01:32:01 PM
I don't think that would work with options or more than one file.
Title: Re: Abiword.scm command line bug
Post by: Rich on April 28, 2012, 01:51:53 PM
Hi curaga
It was intended to handle abiword with one file name. Options and multiple files should be left to someone who
is better versed in scripting than I am.
Title: Re: Abiword.scm command line bug
Post by: Jason W on April 28, 2012, 04:57:19 PM
The Portalbelinuxapps.org method of making portable apps seems to require launching from the .desktop icon, or by clicking the downloaded file, rather than having the flexibility of the command line and switches.  So likely this is a limitation to this kind of extension build.

I can't think of a method to overcome that, I have tried several tricks involving wrappers, but so far a no go.  But it would be nice to find a way to get around this.
Title: Re: Abiword.scm command line bug
Post by: uggla on April 29, 2012, 01:26:11 PM
This should work (but kind of ugly code):

Code: [Select]
#!/bin/sh
SAVE_ARGS=$*
pwd=`echo $PWD`/
options=`echo ' '${SAVE_ARGS} | grep -o -e '[[:space:]][\-]\{1,2\}[[:alnum:]_]\+' | tr '\n' ' '`

absolutefiles=`echo ' '${SAVE_ARGS} | grep -o -e '[[:space:]]/[[:alnum:][:punct:]_/\-]\+' | tr '\n' `
if [ `expr length ' '"${absolutefiles}"` != 1 ]; then
absolutefiles=`echo ${absolutefiles//' '/ \"}\" | tr ' ' \"`;
absolutefiles=${absolutefiles//'""'/\" \"};
fi

relativefiles=`echo ' '${SAVE_ARGS} | grep -o -e '[[:space:]][[:alnum:]_][[:alnum:][:punct:]_\-]\+' | tr '\n' `
if [ `expr length ' '"${relativefiles}"` != 1 ]; then
relativefiles=`echo ${relativefiles//' '/ \"${pwd}}\" | tr ' ' \"`;
relativefiles=${relativefiles//'""'/\" \"};
fi

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

/apps/abiword/abiword ${options} ${relativefiles} ${absolutefiles}
Title: Re: Abiword.scm command line bug
Post by: Rich on April 29, 2012, 01:44:27 PM
Hi uggla
Quote
SAVE_ARGS=$*
Not sure if it matters here, but I think I read somewhere that $@ is more commonly used because it preserves spaces
where $* doesn't in some situations.
Title: Re: Abiword.scm command line bug
Post by: uggla on April 29, 2012, 11:23:27 PM
I'll fix the script for already quoted paths.
Title: Re: Abiword.scm command line bug
Post by: uggla on April 30, 2012, 02:34:03 PM
Here's a much better script:
Code: [Select]
#!/bin/sh

for p do
case ${p:0:1} in
-) params="${params} ${p}";;
/) params="${params} \"${p}\"";;
*) params="${params} \"$PWD/${p}\"";;
esac
done

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

exec /apps/abiword/abiword ${params}
Title: Re: Abiword.scm command line bug
Post by: uggla on May 02, 2012, 03:51:51 AM
Sorry, here's a script that actually works  ;)

Code: [Select]
#!/bin/sh

for arg do
case ${arg:0:1} in
-) SAVE_ARGS="${SAVE_ARGS}${arg}|";;
/) SAVE_ARGS="${SAVE_ARGS}${arg}|";;
*) SAVE_ARGS="${SAVE_ARGS}$PWD/${arg}|";;
esac
done
IFS='|'

cd /apps/abiword
export LD_LIBRARY_PATH="local/lib"
export PATH="local/bin:$PATH"

/apps/abiword/abiword ${SAVE_ARGS}
Title: Re: Abiword.scm command line bug
Post by: Jason W on May 02, 2012, 04:32:01 PM
Hi, I am not ignoring this, time is just tight now, I will visit it soon.
Title: Re: Abiword.scm command line bug
Post by: uggla on May 27, 2012, 08:36:43 AM
Still too busy?  :D
Title: Re: Abiword.scm command line bug
Post by: Jason W on May 27, 2012, 01:42:39 PM
I will look at that last script tonight and  possibly work it in.
Title: Re: Abiword.scm command line bug
Post by: Jason W on May 27, 2012, 04:42:55 PM
Works like a charm with multiple command line arguments, like "/apps/abiword/bin/abiword -u tc /home/tc/file".

I am uploading the fix now, and I will use this approach with the other converted scms.
Title: Re: Abiword.scm command line bug
Post by: uggla on May 27, 2012, 10:00:35 PM
Great!  ;D
Title: Re: Abiword.scm command line bug
Post by: uggla on June 05, 2012, 03:08:21 AM
Xarchiver would be much more useful (to me) if it were updated with this wrapper.