I recently read that during the Civil War, some commanders would fire a warning salvo to allow the enemy to prepare themselves before they attacked with artillery. Is there any truth to do? If so, what was the justification? Chivalry? Thanks.
I've never heard of this, and while I'm not discounting it outright, I will say that the practice seems unlikely if taken at face value. With the exception of a possible isolated instance here and there (and probably very early in the war), it didn't happen with any kind of regularity so far as I know.
Now, an artillery blast might be used to signal another part of an army some ways off that an attack was underway, and that the time had come for them to engage as well. I do recall reading about a few instances where a battle plan was drawn up, and instructions were given to attack when a single, signal artillery blast was given. This was done as a signal to one's own forces, but never as a courtesy to the enemy vis a vis "chivalry" like you mentioned.
When used in an offensive capacity during the ACW, artillery was primarily used to "soften up" an enemy position prior to an infantry attack. It makes no sense whatsoever to give an enemy a warning shot to prepare, for besides the psychological impact artillery is meant to have, its main purpose (as just stated) was to loosen up a fortified position by dropping explosive projectiles into a well-formed and/or entrenched body of soldiers. Giving these enemy soldiers a chance to prepare for this seems ludicrous, and goes against the basic points of artillery use.
If a "warning" shot was ever given, it would have been (I have to imagine, anyway) a smaller battle where the conclusion was foregone, and one commander was trying to demonstrate merciful intentions (probably because they were close to receiving a surrender). Again, though, I never heard of or read about this practice. The only thing I can think of that comes close to it in a large-scale, high-profile scenario is Grant's sieges of Vicksburg and Petersburg. The artillery units there fired on pretty regular schedules (for example, they might shell regularly from 8 a.m. to 5 p.m., then again from 7 p.m. until midnight), which allowed the Confederates enough built-up experience to know when the next barrage was coming, but for a soldier or officer to intentionally warn an enemy: that was an arrestable offense.
[Sources: Bruce Catton, 'Glory Road' & 'Grant Heads South'; James McPherson, 'Battle Cry of Freedom']