Re: .profile not being src'd at login on uptodate buster
On Wed 07 Apr 2021 at 21:46:30 (+0000), Lee wrote:
> On 4/7/21, Marco Ippolito <maroloccio@gmail.com> wrote:
> >> Where I want output, I protect it with:
> >>
> >> [ -n "$PS1" ] && printf …
> >
> > Maybe consider:
> >
> > [[ -t 1 ]] && printf ...
>
> Until your script that was started via crontab silently fails. I
> *like* always having error messages enabled.
Here's the context, from Greg, again:
> Writing error messages to stdout from a .profile isn't generally the
> best idea. Writing to stderr would be slightly better, but both of
> them should be avoided in a permanent configuration if possible. Profiles
> that scribble to stdout or stderr during login can break things like scp.
Agreed, you certainly don't want that to happen when they're doing
their job non-interactively, because it could have major consequential
effects.
> As a *temporary* debugging measure, it's fine.
My start-up files, .bash_profile, .bashrc, and other files that
they source, contain permanent printf commands. When they finish
printing their output, the next thing that's going to happen is
that the shell will emit a prompt. So there's a certain elegance
in using that very prompt as the condition.
The thread, and my comment, was about the topic under discussion,
startup files, not scripts in general. Using PS1 as a condition
in the latter is unlikely to make much sense at all.
Cheers,
David.
Reply to: