How to check BB_DOC_PATH

71 views
Skip to first unread message

consiglieri

unread,
Aug 14, 2020, 8:47:09 AM8/14/20
to BBEdit Talk
Hi
I think I'm having some problems with the path that BB_DOC_PATH., but I'm not sure. How can I check which values BBedit de facto has set for its environmental variables? 

Rich Siegel

unread,
Aug 14, 2020, 9:16:52 AM8/14/20
to bbe...@googlegroups.com
You can echo or print its value, or run a short shell script
which uses `printenv`:

#!/bin/sh
printenv

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <https://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

consiglieri

unread,
Aug 14, 2020, 9:22:20 AM8/14/20
to BBEdit Talk
Printenv does not return the values for BB_DOC_PATH or any other BBedit variable.

Rich Siegel

unread,
Aug 14, 2020, 9:23:46 AM8/14/20
to bbe...@googlegroups.com
On 8/14/20 at 9:19 AM, apel...@gmail.com (consiglieri) wrote:

>Printenv does not return the values for BB_DOC_PATH or any
>other BBedit variable.

Those variables are set only while running a script or filter
*within* BBEdit; so if you run it from a Terminal window or
anywhere else outside of the application, you won't see anything.

consiglieri

unread,
Aug 15, 2020, 11:06:46 PM8/15/20
to BBEdit Talk
The problem I am having is that when running pandoc script in bbedit script folder to convert a markdown file to pdf BBedit saves the generated pdf in a root folder and not in the same folder as the mark-down file.,

Rich Siegel

unread,
Aug 19, 2020, 10:22:16 AM8/19/20
to bbe...@googlegroups.com
On 8/14/20 at 9:33 AM, apel...@gmail.com (consiglieri) wrote:

>The problem I am having is that when running pandoc script in
>bbedit script folder to convert a markdown file to pdf BBedit
>saves the generated pdf in a root folder and not in the same
>folder as the mark-down file.,

One presumes that if you have the path for the Markdown file
you're processing (however you came by it), deriving the path
for the generated PDF should be possible.

BB_DOC_PATH (as I said, it is set when running scripts from the
Scripts menu, at least in current versions) doesn't really
figure in to that calculation.

I suggest modifying your script to use `printenv` to dump the
whole environment, and inspect the output when running from the
Scripts menu.

TJ Luoma

unread,
Aug 19, 2020, 10:47:50 AM8/19/20
to BBEdit MailingList

On Sat, Aug 15, 2020 at 11:06 PM consiglieri <apel...@gmail.com> wrote:

> The problem I am having is that when running pandoc script in bbedit script folder to convert a markdown file to
> pdf BBedit saves the generated pdf in a root folder and not in the same folder as the mark-down file.,

It's hard to be exact without seeing your script, but let's use the basic example pandoc command:

pandoc -o output.html input.txt

Now, if you are in your $HOME folder and ran this command:

pandoc -o output.html /some/other/folder/input.txt

then 'output.html' would be created in your $HOME folder, and not "/some/other/folder/"

so what you really want is

pandoc -o /some/other/folder/output.html /some/other/folder/input.txt

There are a few ways of getting this. The usual way is `dirname`

If you add

DIR=$(dirname /some/other/folder/input.txt)

then DIR would equal /some/other/folder/

and you could use

pandoc -o "$DIR/output.html" /some/other/folder/input.txt

to get both files in the same directory.

So, going back to the BBEdit example, if `$BB_DOC_PATH` has the full path to the file, you could use

DIR=$(dirname "$BB_DOC_PATH")

In zsh you don't need to use `dirname` you can use `:h` at the end of the variable, like so:

DIR="$BB_DOC_PATH:h"

That will give you the `head` of the path, which is equal to the dirname.

Putting all of that together,

Example #1 (bash):

DIR=$(dirname "$BB_DOC_PATH")

pandoc -o "$DIR/output.html" "$BB_DOC_PATH"

Example #2 (zsh)

DIR="$BB_DOC_PATH:h"

pandoc -o "$DIR/output.html" "$BB_DOC_PATH"

I hope that's helpful. If you need more info, please feel free to ask.

Tj




Reply all
Reply to author
Forward
0 new messages