[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: at based alarm.



On Thu, Feb 15, 2018 at 08:19:25AM -0800, peter@easthope.ca wrote:
> *	From: Greg Wooledge 
> > xterm -display :0 -e bash -c '. ~/.bashrc; wake'
> 
> You've lost me.  That command is for a wake function rather than 
> script?  ~/.bashrc is necessary to declare the function before it is 
> invoked?  What is the period preceding ~/.bashrc?

You're conflating a few things from the earlier parts of the thread.

The command quoted above is for the use of a wake function that's
defined in ~/.bashrc rather than a script.  In order for the function
to work, its definition has to be read and executed as a command.
Which means the contents of ~/.bashrc have to be read and executed.
That's what dotting in does.

The . command reads the contents of a file and executes it as a
series of shell commands in the CURRENT shell instead of as a
child-process script.  This is called "dotting in".  The syntax was
invented in the 1970s.  Bash offers the "source" command as a
synonym for "." so that people don't keep asking this question
over and over.

The . command was already used by someone else in the thread, so I
didn't change it to source.

If you go with a script named wake (instead of a function named wake)
then you don't have to worry about any of this.

> When that is invoked interactively, the xterm window opens and 
> immediately closes.  No evidence of the wake function executing.

We'd have to see your ~/.bashrc and the actual command you executed.

> For the wake script, both of these work interactively.
> xterm -display :0 -e bash -c '~/wake'
> xterm -display :0 -e ~/wake
> 
> > It would be a lot simpler to put the script in ~/bin/wake though.
> 
> I'm happy to use a script rather than function.  Is the ~/bin location 
> significant?  Would ~ work just as well?

$HOME/bin is the traditional place to put personal shell scripts and other
commands.  Usually one ensures that this directory is part of PATH so
that they can simply be invoked as commands in interactive shells.

Note that the default Debian ~/.profile file in stretch will add
$HOME/bin to your PATH for you, if your login method includes the
reading of this file at all.  Sadly, Display Manager logins do not.


Reply to: