# history



## balanga (May 11, 2021)

When I display my command history I get someting like:-


```
1011    8:01    history
  1012    8:09    cd "`printf '%b' '\0057mnt\0057tmp'`"
  1013    8:09    cd "`printf '%b' '\0057mnt\0057tmp\0057bin'`"
  1014    8:33    cd "`printf '%b' '\0057mnt\0057tmp'`"
  1015    8:33    cd "`printf '%b' '\0057mnt'`"
  1016    8:34    umount /mnt/tmp
```

Is there any way to avoid this 'cd printf' stuff? It just gets in the way. It doesn't occur on Linux. Is it configurable in some way?


----------



## SirDice (May 11, 2021)

What's your prompt set to? Because these look like parts of a 'dynamic' prompt.


----------



## balanga (May 11, 2021)

I'm just using a standard installation. Not configured anything...
This is part of my ~/.cshrc, ie what comes with the installation:-

```
if ($?prompt) then
<------># An interactive shell -- set some stuff up
<------>set prompt = "%N@%m:%~ %# "
<------>set promptchars = "%#"

<------>set filec
<------>set history = 1000
<------>set savehist = (1000 merge)
<------>set autolist = ambiguous
<------># Use history to aid expansion
<------>set autoexpand
<------>set autorehash
<------>set mail = (/var/mail/$USER)
<------>if ( $?tcsh ) then
<------><------>bindkey "^W" backward-delete-word
<------><------>bindkey -k up history-search-backward
<------><------>bindkey -k down history-search-forward
<------>endif

endif
```


----------



## SirDice (May 11, 2021)

An alias perhaps? Those are 'expanded' before being added to the history.



balanga said:


> I'm just using a standard installation.


What's your user's shell set to?


----------



## mark_j (May 11, 2021)

SirDice  is on the right track. This looks like the crap midnight commander used to produce back in the day when i used it.

Sorry, I don't have the answer at hand.


----------



## jmos (May 11, 2021)

Midnight Commander was my first thought, too. If it is used on the OPs machine: You'll get rid of it by compiling the port without subshell support.


----------



## balanga (May 11, 2021)

I do use Midnight Commander extensively. Is that what is causing it? The same doesn't happen when I use it under Linux.


----------



## fraxamo (May 11, 2021)

https://forums.freebsd.org/threads/midnightcommander-and-history.58865/


----------



## balanga (May 11, 2021)

Looks like someone else has the same problem...

https://midnight-commander.org/wiki/doc/faq#a6.8WhyIseelotofstrangecdprintflinesintomy.historyfile 

the solution:-



> Add export HISTCONTROL="ignoreboth" into your ~/.profile file (.bash_profile) for avoid this.



What should I do on FreeBSD? Should I add that line to my ~/.cshrc


----------



## mark_j (May 11, 2021)

balanga said:


> I do use Midnight Commander extensively. Is that what is causing it? The same doesn't happen when I use it under Linux.


It's probably not an option that's compiled in on whatever-version-of-linux. Either build it from ports or change your shell; they seem to be the only options.


----------



## balanga (May 14, 2021)

mark_j said:


> It's probably not an option that's compiled in on whatever-version-of-linux. Either build it from ports or change your shell; they seem to be the only options.


I thought I'd try building it, but get 'Invalid perl5 version 5.32'..

I can see this being a marathon session get it built.


----------



## SirDice (May 14, 2021)

balanga said:


> I thought I'd try building it, but get 'Invalid perl5 version 5.32'..


What did you set in /etc/make.conf?


----------



## balanga (May 14, 2021)

Well someone had a similar problem - Thread 77628

Solution - Thread 77628/#post-483641 - `pkg install -f perl5`

Doesn't work - same error occurs with `make mc`


----------



## balanga (May 14, 2021)

SirDice said:


> What did you set in /etc/make.conf?


I didn't have an entry but have now added:-

```
DEFAULT_VERSIONS+=perl5=5.32
```
Doesn't make any difference but I guess I put in the wrong value.


----------



## balanga (May 15, 2021)

jmos said:


> Midnight Commander was my first thought, too. If it is used on the OPs machine: You'll get rid of it by compiling the port without subshell support.


Everyone says not to mix ports and packages


----------



## balanga (May 15, 2021)

Just found this in https://midnight-commander.org/wiki/doc/faq


> 6.8 Why I see lot of strange 'cd "printf ' lines into my .history file?​Add export HISTCONTROL="ignoreboth" into your ~/.profile file (.bash_profile) for avoid this.



Doesn't seem to work for me. Has anyone else tried it?


----------



## Alain De Vos (May 15, 2021)

I have also history issues. (no kidding...).
Lots of .history files of length 0.


----------



## balanga (May 15, 2021)

balanga said:


> balanga said:
> 
> 
> > Just found this in https://midnight-commander.org/wiki/doc/faq





balanga said:


> balanga said:
> 
> 
> > Add export HISTCONTROL="ignoreboth" into your ~/.profile file


Doesn't seem to work for me. Has anyone else tried it?

When I try saving ~/.profile  I get a warning saying the file has hard-links. Detach before saving?

Not sure what to reply...


----------



## Tieks (May 15, 2021)

Your ~/.profile will be hard-linked to /.profile.  If you don't want to change /.profile (root rights needed for that), you need to detach it. Then it will be saved as a file in your home dir without link.


----------



## Alain De Vos (May 15, 2021)

I removed the line "set histfile". I don't know if it helps.


----------



## jmos (May 17, 2021)

balanga said:


> Everyone says not to mix ports and packages


I don't agree. It can make trouble, but it mustn't. In case of Midnight Commander I'm doing this for years without an issue, and otherwise you won't get rid of your "broken" history (afaik…: or use Bash as shell?). Other ports like LibreOffice have much more potential for problems when mixing ports and packages, and IMO if your doing this you should be able to interpret errors accordingly (!) and know when you've got to recompile your selfmade packages; Also you should use a ports tree matching your package repository as best as possible.


----------



## balanga (May 18, 2021)

jmos said:


> Midnight Commander was my first thought, too. If it is used on the OPs machine: You'll get rid of it by compiling the port without subshell support.


Just looked at the Makefile and 'subshell' is mentioned quite a few times, so not sure how to remove its support...


----------



## T-Daemon (May 19, 2021)

balanga said:


> Just looked at the Makefile and 'subshell' is mentioned quite a few times, so not sure how to remove its support...


You have the tendency to make things unnecessarily complicated. Just run `make config` .


----------



## balanga (May 19, 2021)

I prefer it if things are simple, just not familiar making objects with lots of objects.

What does `make config` actually do? Modify the Makefile?


----------



## Tieks (May 19, 2021)

It will write your chosen options to /var/db/ports/<port name>/options. Using `make rmconfig` you remove that file.


----------



## balanga (May 19, 2021)

Many thanks, I never knew this.


----------



## balanga (May 19, 2021)

After removing subshell I realise that I can't use C-o any more so that is useless. I just want to be able to use misc/mc on FreeBSD the same way I use it on Linux, ie C-o brings up a command window and up and down scrolls through my history without any of this "print" crap.

Maybe it's a configuration option..


----------



## balanga (May 27, 2021)

Coming back to an unresolved thread... I was just using misc/mc  on FreeNAS, which seems to have it included and noticed there was none of this "`printf '%b' '\0057mnt\0057tmp'`" nonesense and wondered why that would be so did a comparison of `mc -V`...
On FreeNAS

```
GNU Midnight Commander 4.8.24
Built with GLib 2.56.3
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish, smbfs
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
```
As a normal FreeBSD pkg

```
GNU Midnight Commander 4.8.26
Built with GLib 2.66.7
Built with S-Lang 2.3.2 with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish, smbfs
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
```
so it looks like subshell support is not responsible for all crap.  I could try using the FreeNAS build on FreeBSD and see if it makes a difference. Is there any reason it wouldn't run?


----------



## SirDice (May 27, 2021)

I use mc quite regularly, my shell is set to tcsh(1) and use that subshell quite often too. Don't have those entries in the command history though.


----------



## Phishfry (May 27, 2021)

balanga said:


> none of this "`printf '%b' '\0057mnt\0057tmp'`" nonesense


I think it helps to analyze your irritant.
Notice how it has "mnt" in it and some sort of temp file.

So what would cause things to mount in command prompt? Do you have gvfs installed?
`pkg info |grep gvfs`
It does some blatant stuff and I would start there on my box.

Another way to analyze this is to use a new install with just mc and pkg installed. See if acts the same.
My gut feeling is this is some other package involved.


----------



## Phishfry (May 27, 2021)

balanga said:


> With support for X11 events


Notice the diff


----------



## balanga (May 27, 2021)

Not sure where this comes from or what it really means, but could it be responsible for all my 'printfs' ?


```
set echo_style=both ; set prompt='%n@%m:%~%# ' ; alias precmd 'echo -n;echo $cwd:q >>/tmp/mc-root/mc.pipe.58385; kill -STOP $$'
```


----------



## jmos (May 28, 2021)

Port has been updated ("Tell users that /bin/sh, our base system sh(1), is not supported as concurrent subshell because it does not allow "precmd" hooks"):





						208391 – misc/mc SUBSHELL not working with /bin/sh
					






					bugs.freebsd.org
				




Hey balanga, I gave you another hint: Simply use another shell (so mc's history don't bother your "real" one); What about that solution? Be creative  You can f.e. use an alias to start mc in another shell…


----------



## Alain De Vos (May 28, 2021)

That's right. My recovery toor shell is a staticly linked oksh copied to /bin


----------



## SirDice (May 28, 2021)

balanga to what is your user's shell set to? You kept mentioning .cshrc, does that mean it's set to csh(1) or tcsh(1)?


----------



## balanga (May 31, 2021)

SirDice said:


> balanga to what is your user's shell set to? You kept mentioning .cshrc, does that mean it's set to csh(1) or tcsh(1)?


When I type in `set`, I'm told



> shell    /bin/csh


I don't really mess about with these things, tend to use what's installed by default.


----------

