WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Abiword.scm command line bug  (Read 6085 times)

Offline uggla

  • Sr. Member
  • ****
  • Posts: 438
Abiword.scm command line bug
« on: April 27, 2012, 07:06:06 AM »
With the current /apps/abiword/bin/abiword the following command doesn't work:
abiword mydoc.abw


Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #1 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.

Offline uggla

  • Sr. Member
  • ****
  • Posts: 438
Re: Abiword.scm command line bug
« Reply #2 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 "$@"

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #3 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.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7342
Re: Abiword.scm command line bug
« Reply #4 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?

Offline uggla

  • Sr. Member
  • ****
  • Posts: 438
Re: Abiword.scm command line bug
« Reply #5 on: April 27, 2012, 10:10:42 AM »
vlc.scm has the same bug.

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #6 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.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7342
Re: Abiword.scm command line bug
« Reply #7 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/$@"

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #8 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.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7342
Re: Abiword.scm command line bug
« Reply #9 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

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #10 on: April 28, 2012, 11:38:12 AM »
Thanks Rich, I will check those out.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10152
Re: Abiword.scm command line bug
« Reply #11 on: April 28, 2012, 01:32:01 PM »
I don't think that would work with options or more than one file.
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 7342
Re: Abiword.scm command line bug
« Reply #12 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.

Offline Jason W

  • Administrator
  • Hero Member
  • *****
  • Posts: 9668
Re: Abiword.scm command line bug
« Reply #13 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.

Offline uggla

  • Sr. Member
  • ****
  • Posts: 438
Re: Abiword.scm command line bug
« Reply #14 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}